301 Redirects, and the correct regex to go with it

Posted by Tisch on Stack Overflow See other posts from Stack Overflow or by Tisch
Published on 2010-06-14T13:07:37Z Indexed on 2010/06/14 13:12 UTC
Read the original article Hit count: 342

Filed under:
|
|

Hi Guys,

I have several URLs that I want to redirect to the same place, however these are dynamic URLs.

The structure is something like this:

http://www.mysite.com/declaration/list?[query_string]

What I think would be ideal for this situation is to use some regex in my .htaccess file to redirect all these links to the sites home page.

I was wondering if someone could help me with the regex for this situation. So far, I have this, but it doesn't work:

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^/declaration/list$ http://www.mysite.com/$ [R=301,L]

My regex is weak to say the least, something I want to, and am trying to learn.

Thanks in advance. Tom

© Stack Overflow or respective owner

Related posts about regex

Related posts about .htaccess