Reputation: 105
I have pages with the following parameters: /article.php?sid=123&cat1=en
I need to change that cat1
to cat
and redirect to the same address.
I've tried RewriteRule ^/article.php?sid=(.*)&cat1=(.*)$ /article.php?sid=$1&cat=$2 [R=301,L]
but it's not working.
Upvotes: 1
Views: 37
Reputation: 786091
You can use this rule to match & replace a given query parameter at any position.
Keep this rule as your very first rule:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*&)?cat1=([^&]*(?:&.*)?)$ [NC]
RewriteRule ^article\.php$ %{REQUEST_URI}?%1cat=%2 [R=301,NE,L]
Upvotes: 1