Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to create a 301 redirect based purely on a query string see b

New URL: newurl.php?var=yup

My normal way of doing this would be

redirect 301 pc=/product/9999 newurl.php?var=yup

But this time I am trying to match a URL that that only contains the domain and a query string...

What is the best way of doing this?


share|improve this question

I used the following to solve my problems:

RewriteCond %{QUERY_STRING} ^pc=/product/9999
RewriteRule (.*) [L,R=301]


share|improve this answer

I believe this is what you want.

RewriteCond %{HTTP_HOST} ^olddomain\.com$ [NC]
RewriteRule ^\?pc=/product/9999$ http://newdomain/newurl.php?var=yup [NC,R=301,L]

RegEx could be a little off. I did that off the top of my head.

share|improve this answer
Thanks, but as it happend i just solved it myself.. Check my answer – icelizard Mar 23 '10 at 17:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.