3

We've installed a new shop software and I've set up redirects for all of the old pages, but there's one that I just can't get to work. If the url includes

cp_tpl=productlist.html

then I want to redirect to the main website. So for example the old url could be

http://www.gocellular.ca/index.php?cp_tpl=productlist.html&cp_cat=803&cp_sid=1xxxxxx

and I want to redirect to

www.gocellular.ca

The 'cp_tpl=productlist.html' can be anywhere in the url - basically I just want to check if the string 'cp_tpl=productlist.html' is included anywhere in the url and then redirect. I've tried about 100 different .htaccess re-writes but just can't get this to work! I'd be very grateful for any ideas.... THANK YOU!

2
  • List some of the RewriteRules you've tried. Commented Nov 8, 2010 at 1:53
  • Is RewriteRule cp_tpl=productlist\.html http: //www.gocellular.ca/ [R,L] not working? (Without the space after http: of course.) Commented Nov 8, 2010 at 1:54

1 Answer 1

4

In order to catch that string in the query string as you have shown it there you have to use a RewriteCond, as the regular expression doesn't get checked against the query string in a redirect rule. Something like this should do the trick:

RewriteCond %{QUERY_STRING} cp_tpl=productlist.html
RewriteRule .* / [R,L]

The above will keep the query string intact. If yow want to remove the query string, just add a ? after /, i.e.:

RewriteRule .* /? [R,L]
Sign up to request clarification or add additional context in comments.

2 Comments

I have implemented this but it didn't worked for me. If my url contains word 'forum' then it should be redirects to 83answers.com. I wrote following in my htaccess RewriteCond %{QUERY_STRING} forum RewriteRule .* 83answers.com [R,L] But it didn't work, please help me to sort this out
This question is specifically about the query string. Something along the lines of RewriteRule forum 83answers.com [R,L] should cover the rest of the URL.

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.