Webmasters Stack Exchange is a question and answer site for pro webmasters. 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 trying to redirect a page via my .htaccess, but it does not seem to be working.

Old page: /dyn/?q=customer%20reference&f=1,1,1,1,1,1&c=10,10,10,10,10,10&s=1,1,1,1,1,1,1&st=1

New page: /customer-references/

So it should be as simple as this:

RewriteEngine On
RewriteCond %{QUERY_STRING}  ^q=customer(?:[\ +]|%20)reference&f=1$ [NC]
RewriteRule ^dyn/$ /1? [R=301,NE,NC,L]

But it does not seem to be working. Is it because the original page's dynamic URL?

The new page is actually a different physical php page if that matters.

BTW, I also tried a straight 301 Redirect in the .htaccess. That didn't seem to work either:

redirect 301 /dyn/?q=customer%20reference&f=1,1,1,1,1,1&c=10,10,10,10,10,10&s=1,1,1,1,1,1,1&st=1 /customer-references/

And another failed attempt was this:

RewriteCond %{QUERY_STRING} ^customer%20reference&f=1,1,1,1,1,1&c=10,10,10,10,10,10&s=1,1,1,1,1,1,1&st=1$
RewriteRule ^$ http://www.domain.com/customer-references/? [R=301,L]

Am I making this more difficult than it needs to be?

share|improve this question
Your RewriteRule replaces the URL which is dyn/ (nothing else). Try getting rid of the $ after dyn/ – paulmorriss Jan 25 '12 at 14:19
Removing the $ after dyn in the RewriteRule doesn't seem to do it. Can I hard code the "/?q=customer%20reference&f=1,1,1,1,1,1&c=10,10,10,10,10,10&s=1,1,1,1,1,1,1&st=1‌​" in the RewriteRule? – Keefer Jan 25 '12 at 14:45
Not sure. Another problem is the $ after $f=1$ in RewriteCond. That means you only look for strings that end like that, and so won't match f=1,1,1,1, etc. – paulmorriss Jan 25 '12 at 16:50

This did it, though I can't take credit for finding the solution on my own. Sister site stackoverflow offered up the proper code for .htaccess

RewriteCond %{QUERY_STRING}  ^q=customer%20reference&f= [NC]
RewriteRule ^dyn/$ /customer-references/? [L,R=301]
share|improve this answer

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.