Reputation: 69
Via .htaccess
, I would like to create an automatic 301 from an old URL to a new url:
An example old url is: http://www.example.com/test.html?s=2&ss=3
I would like that to be automatically redirected to: http://www.example.com/test.html
Upvotes: 0
Views: 39
Reputation: 785866
If you want to match this specific URL and query parameters then you can use this rule in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^s=2&ss=3^ [NC]
RewriteRule ^test\.html$ %{REQUEST_URI}? [L,R=302]
If you want to use this query string with any URI then use:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^s=2&ss=3^ [NC]
RewriteRule ^ %{REQUEST_URI}? [L,R=302]
?
after %{REQUEST_URI}
is needed to strip off any query string.
Upvotes: 1