Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^Detail=News&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=About&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Contact&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Catalog&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Login&Department=$
RewriteRule ^(index\.php)?$ - [G]
RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule [R,L] (http://www.mysite.com)
By ending each pattern with an end anchor "$", you are telling mod_rewrite to match that exact string and only that exact string.
Reference: [etext.lib.virginia.edu...]
Also, this last Rule was backwards... should be:
RewriteRule .* [mysite.com...] [R,L]
HTH,
Jim
RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule ^(index\.php)?$ [mysite.com...] [R=301,L]
Jim
RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule ^(index\.php)?$ [mysite.com...] [R=301,L]
How can I use both? If I redirect with .htaccess then how would the bots see the 404?
If you have a direct replacement for a page, use a 301. The old URL will be replaced with the new one.
If there is no direct replacement for a given page, use a 410 - or a 404 if you have to - and redirect via ErrorDocument to a custom error page containing links to your home page and/or a site index page. These pages will be removed from the index, but visitors will still be able to find what they're looking for through the index page or site map.
You can define custom error documents using the ErrorDccument [httpd.apache.org] directive:
ErrorDocument 410 /this_page_is_gone.html
The ErrorDocument defined for 410 will be invoked by your rules which include the [G] (Gone) flag.
You've got 99% of everything right - Just figure out how you want to handle each specific page you've removed.
Jim
I recommend that you use a 410 for pages you know are gone, and reserve 404 for unexpected problems. It makes sorting out your log files much easier.
Use the WebmasterWorld Server Header Checker [webmasterworld.com] to check your 'dead' page URLs. If you see a 410 or 404 response, that page will be dropped by the search engines. If you see a 301 response, that URL will be replaced with the new one. If you see a 302, then the search engine will do nothing except index the new page contents using the old URL.
Jim