Ruchika
Ruchika

Reputation: 515

Htaccess Redirection for url with matching string

Need help on 301 redirection for all string matches 'start' parameter in oldtoys

Incorrect URL been generated

http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&start=45&limitstart=300
http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&start=30&limitstart=275
http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&start=15&limitstart=250

Correct URL

http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&limitstart=300
http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&limitstart=275
http://www.abc.com/index.php?option=com_oldtoys&view=category&Itemid=2&limitstart=250

This only pertains to old toys component Can someone help on it

Upvotes: 2

Views: 697

Answers (2)

Jon Lin
Jon Lin

Reputation: 143896

Using mod_rewrite:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(option=com_oldtoys&.*)&start=[0-9]+(.*)$
RewriteRule ^index\.php$ /index.php?%1%2 [L,R=301]

Upvotes: 2

anubhava
anubhava

Reputation: 785196

You can use this rule:

RewriteCond %{QUERY_STRING} ^(option=com_oldtoys&view=category&Itemid=[^&]*)&start=[^&]*&(limitstart=[^&]*) [NC]
RewriteRule ^index\.php$ $0?%1&%2 [L,NC,R=301]

Upvotes: 1

Related Questions