Reputation: 387
Can anyone help with .htaccess URL rewriting rule.
I need to redirect pages like this:
www.website.com/index.php?a=some-word-some-other-word
www.website.com/index.php?a=something
www.website.com/index.php?a=some-other-thing
All that pages have the same content as www.website.com/index.php
to
www.website.com/index.php or www.website.com/
I already asked for this and I got this:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.website.com/? [R=301,L]
It does that, it redirect those pages to home page (root of site). But I have some pages with URLs like:
i.php?a=something-something-something
and problem is that .htaccess code above affect those links too.
Can anyone make that code just to redirect links for pages based on index.php?a=
and not for i.php?a=
too.
Upvotes: 0
Views: 79
Reputation: 15816
Try this and tell me if it works:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule ^index\.php$ http://www.website.com/? [R=301,L]
Upvotes: 1