-1

How i can modify url path likeexample.com/blog_id=4&comment_id=5 to just example.com without redirection. so the content gonna be of that long url but after loading page it modifies it to that short url.

which_part
  • 792
  • 3
  • 11
  • 26

2 Answers2

2

Use javascript pushstate to clear your URL after page load.

window.history.pushState("object or string", "Title", "/");

Santhosh Nayak
  • 2,312
  • 3
  • 35
  • 65
2

Your questions seems like .htaccess good usage:

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

You can also use JS window.history for that:

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

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

Community
  • 1
  • 1
Justinas
  • 41,402
  • 5
  • 66
  • 96