Forum Moderators: phranque

Message Too Old, No Replies

Mod_Rewrite Problem

Problems using mod_rewrite on old urls with .php?cat= in them.

         

Symbios

4:47 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



Hi,

I have some old pages showing up as supplemental results, these pages no longer exist but if you click on a link to say index.php?cat=oldpage index.php will be displayed, this could get the site a duplicate content so I've been playing with mod_rewrite and 301 redirects to get rid of the problem without success, at the moment I'm using;

RewriteRule ^index\.php?cat=oldpage$ /different-url.html [R=301,L]

Which doesn't work, I also tried;

redirect 301 /index.php?cat=oldpage ht#p://w#w.domain-name.com/different-url.html

Unfortunately its not working, I've done a test that worked fine with;

RewriteRule ^nonexistent_file\.html$ /different-url.html [R=301,L]

So my guess is that its something to do with .php?cat=### , any ideas would be appreciated.

jdMorgan

5:01 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to use RewriteCond %{QUERY_STRING} in mod_rewrite to test and manipulate query strings appended to URLs.

Jim

Symbios

6:22 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



Jim,

Thanks for the pointer, in the end I used;

rewritecond %{query_string} ^cat=oldpage
rewritecond %{HTTP_HOST} ^(.*)$
RewriteRule ^(.*)$ [%1...] [R=301,L]