Forum Moderators: phranque
####
ErrorDocument 410 /410.htm
Options +FollowSymlinks
RewriteEngine on
#### Serve MSNBot a 'Gone' response for any page on this site
RewriteCond %{HTTP_USER_AGENT} ^msnbot [NC]
## Exclude the 410 document
RewriteCond %{REQUEST_URI}!^/410.htm
## All other documents are gone
RewriteRule .* - [G,L]
## Redirect everyone else to the new site
Redirect 301 / http://www.mynewsite.com/doodads/
[edited by: jdMorgan at 3:53 pm (utc) on Dec. 10, 2006]
[edit reason] De-linked [/edit]
Each Apache module processes your .htaccess file in turn and acts only on the directives it recognizes. Therefore, the sequential dependency implied by your directive order is not what will actually happen.
The order in which Apache modules process your file is determined in Apache 1.x by the order the modules appear in the LoadModule list: Execution order is the reverse of that list order. In Apache 2.x, execution order is determined by an internal priority scheme.
Therefore, one cannot depend on line order to control logical execution order; In this case, your Redirect directive will be executed first on almost all normal Apache installations, and your mod_rewrite code will never apply.
The solution is to use only directives from the same Apache module when execution order is critical:
ErrorDocument 410 /410.htm
#
Options +FollowSymlinks
RewriteEngine on
#
# Serve MSNBot a 'Gone' response for any page on this site except the 410-Gone error document
RewriteCond %{HTTP_USER_AGENT} ^msnbot [NC]
RewriteRule !410\.htm$ - [G]
# Redirect everyone else to the new site
RewriteRule (.*) http://www.mynewsite.com/doodads/$1 [R=301,L]
Jim
By chance, I came across a post on WebmasterWorld that said that a '410 Gone' response could only be understood by Agents which used the HTTP/1.1 protocol.
It looked like most search engine bots still use 1.0, and thus serving up a '404' response would be smarter.
I can't get this code to work on my server, but I'm trying to do too many things at once at the moment, so I'll leave it for now.
Jim
The browser won't re-fetch a locally-cached file from the server unless the cache entry is expired or the cache-control headers returned with the originally-fetched file marked it as uncacheable or requiring revalidation.
Jim
One more try, one more flush:
ErrorDocument 410 /410.htm
#
Options +FollowSymlinks
RewriteEngine on
#
# Bypass all following rules for custom error document requests
RewriteRule ^410\.htm$ - [L]
#
# Serve MSNBot a 'Gone' response for any page on this site except error documents
RewriteCond %{HTTP_USER_AGENT} ^msnbot [NC]
RewriteRule .* - [G]
# Redirect everyone else to the new site
RewriteRule (.*) http://www.mynewsite.com/doodads/$1 [R=301,L]