1

Need Guidance of 301 redirecting Url through htaccess matching specific format

Existing URL

http://www.example.com/index.php?option=com_toys&limitstart=20

Proposed URL

http://www.example.com/index.php?option=com_toys&view=list&Itemid=2&limitstart=20

Here limitstart may change to 0,20,40,60 to even 1000 and thus should remain same in the new proposed url too

Can anyone advise on to redirect using htaccess of above

2
  • This sounds more like a PHP issue than an .htaccess issue. Aren't you passing through Itemid and view as _GET parameters? Commented Jul 24, 2017 at 3:55
  • Well i am but unfortunately Google crawl has crawled some pages like the existing url, so as to have sync - is considering a htaccess solution so as to redirect all in same format as in proposed url. Commented Jul 24, 2017 at 3:59

1 Answer 1

1

You need to match query string using RewriteCond using a regex to capture both parameters:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(option=com_toys)&(limitstart=\d+)$ [NC]
RewriteRule ^/?index\.php$ %{REQUEST_URI}?%1&view=list&Itemid=2&%2 [L,NC,R=301]
Sign up to request clarification or add additional context in comments.

3 Comments

Hi thanks - but its displaying in incorrect url :- http://www.example.com/index.php?view=list&Itemid=2&option=com_toys&limitstart=120 instead of http://www.example.com/index.php?option=com_toys&view=list&Itemid=2&limitstart=120
It is actually same URL just that parameters are in different order.
This will impact in Search as Google crawl will treat it as duplicate url, is it possible to get parameters in same order

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.