Hi!

I try to redirect users (301 redirect)
from http://www.example.com/product.asp?productID=1
to http://www.example.com/newurl

To do this I wrote in .htaccess file:
RewriteRule ^product.asp?productID=1$ http://www.example.com/newurl [R=301,L]

But it doesn't have effect.

As I understand the problem is in ? char, because next rule work fine:
RewriteRule ^product.aspproductID=1$ http://www.example.com/newurl [R=301,L]

Does anyone can help me?

Comments

sidharth_k’s picture

How about

RewriteRule ^product.asp\?productID=1$ http://www.example.com/newurl [R=301,L]

Does this help?

There is plenty of regex / URL rewriting help available on the web. Just google for mod_rewrite or regex .

For instance check out:

http://www.regular-expressions.info/reference.html

siteograf’s picture

In this topic I found solution: http://drupal.org/node/38960

If you have next URL:
http://www.example.com/product.asp?productID=1
? mark after some letters (not /)
You need to write next rules:

RewriteCond %{THE_REQUEST} productID=1
RewriteRule . http://www.example.com/newurl? [R=301,L]

=========================
If you have next URL:
http://www.example.com/?productID=1
? mark after /
You need to write next rules:

RewriteCond %{QUERY_STRING} ^productID=1$
RewriteRule ^$ http://www.example.com/newurl? [R=301,L]