在javascript或CI中按下浏览器后退,前进或刷新按钮时,如何将页面重定向到特定URL

I have created a page using Codeignitor , Ajax and javascript which is just like dynamic dropdown selection. This is my localhost URL.

http://localhost/nwfnb/sbi-bank/ifsc-code/andaman-and-nicobar/andaman/aberdeen-bzr-evening-city.

What i want here is when a user press backword or forward or refresh button then I want URL like this.

http://localhost/nwfnb/sbi-bank/ifsc-code.

This is just a single view page code using Ajax and CI. I am just mentioning the second selection option code.

View:

 $('#state').on('change',function(){
                    var stateID = $(this).val();
                    var countryName=  $('#country option:selected').text().toLowerCase();
                    var stateName=  $('#state option:selected').text().toLowerCase();
                    if(stateID){
                        $.ajax({
                            type:'POST',
                            url:'<?php echo base_url('bank/getBranch'); ?>',
                            data:'state_id='+stateID,
                            success:function(data){
                                $('#city').html('<option value="">Select City</option>'); 
                                var dataObj = jQuery.parseJSON(data);
                              //  alert (dataObj);
                                if(dataObj){
                                    $(dataObj).each(function(){
                                        var option = $('<option />');
                                       // alert(option);
                                        option.attr('value', this.id).text(this.branch_name);           
                                        $('#city').append(option);
                                        window.history.replaceState("", "", "<?php echo base_url(); ?>sbi-bank/ifsc-code/"+countryName+"/"+stateName);
                                      //  window.location = "//www.aspsnippets.com/"; 
                                    });
                                }else{
                                    $('#city').html('<option value="">Branch not available</option>');
                                }
                            }
                        }); 
                    }else{
                        $('#city').html('<option value="">Select district first</option>'); 
                    }
                });

Is there any way to get only the above mentioned url using CI or javascript