How to redirect dynamic urls to their relevant sta

2019-07-24 17:27发布

问题:

Dynamic urls are like

example.com/wp/?2323e=467467
example.com/any-page.html?2323e=567856
example.com/any-folder/other-page.html?2323e=6435346

I want to redirect them all to their static urls like

example.com/wp/
example.com/any-page.html
example.com/any-folder/other-page.html

please suggest how to do this using 301 redirect

回答1:

To remove query strings, you can use :

RewriteEngine on


RewriteCond %{QUERY_STRING} .+ [NC]
RewriteRule ^ %{REQUEST_URI}? [L,R]

This will redirect :

/foo?querystring

to

/foo