Ruchika
Ruchika

Reputation: 515

htaccess redirect of url matching specific format

The Bing bot shows that some of the url structure been misaligned is it a way to forward all urls starting with ?id parameter after the domainname to redirect to home page. The id changes according to product page

http://www.abc.com/?id=100&itemid=2&option=com_toys&view=post - Incorrect url
http://www.abc.com/index.php?option=com_toys&view=post&id=100&Itemid=2 - correct url

Have tried using

RewriteCond %{REQUEST_URI} ^.*/?id.*$
RewriteRule .*  index.php     [R=301,L]

but its not working, any suggestions to achieve the same !!

thanks

Add on

Hi - could you advise on one more on it

http://www.abc.com/index.php?Itemid=2&id=100&option=com_toys&view=post - Incorrect url
http://www.abc.com/index.php?option=com_toys&view=post&id=100&Itemid=2 - correct url

That is if the pattern matches :- Itemid immediately after index.php, how to redirect it too to home page

Upvotes: 0

Views: 153

Answers (1)

Amine Hajyoussef
Amine Hajyoussef

Reputation: 4430

replace your rule with:

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=.*
RewriteRule ^$  /?     [R=301,L]

Upvotes: 1

Related Questions