Removing Parameters from a URL

I want to remove the parameter after the true url and then redirect to the same URL without this parameter

example:

I want to remove the "r" parameter from

http://www.mysite.com/123.html?r=1

and redirect to

http://www.mysite.com/123.html

using htaccess and 301 redirect

Thank you

+3
source share
2 answers

Try the following:

RewriteRule ^123.html.? 123.html? [L]

Note that the second URL ends with ?, this removes the query string.

Source: http://wiki.apache.org/httpd/RewriteQueryString

+6
source

, ?, qsdiscard QSD, redirect R=301. , :

RewriteRule ^123\.html(.*)$ 123.html [QSD,L,R=301]
0

Source: https://habr.com/ru/post/1782245/


All Articles