user6813858 user6813858 - 7 months ago 59
Javascript Question

Modify url path without redirection

How i can modify url path like

to just
without redirection.
so the content gonna be of that long url but after
loading page it modifies it to that short url.


Your questions seems like .htaccess good usage:

RewriteEngine On 
RewriteRule ^/blog_id=\d+&comment_id=\d+$ [NC,L]

You can also use JS window.history for that:

var stateObj = {blog_id: 4, comment_id: 5};
history.pushState(stateObj, "", "");
history.replaceState(stateObj, "", "");

Difference: when pushState and clicking back button you will be redirected to previous URL while replaceState will redirect to actual previous page that you visited before using replaceState