Today now in this blog i will show you how to remove query string from url by using Jquery. Now here we will know how and why need to remove.
Why remove query strings?
Here is main two reasons for this.
- Clear URL always look better than the long URL
- When we are not remove our query string from URL. then all get variable show in our URL string. sometime it not good for a security
we can remove your query string using this simple Jquery code.
$(document).ready(function(){
var uri = window.location.toString();
if (uri.indexOf("?") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("?"));
window.history.replaceState({}, document.title, clean_uri);
}
});
Read Also : How to store all record in laravel Cache
Thanks for read. I hope it help you. For more you can follow us on facebook.