Forum Moderators: phranque

Message Too Old, No Replies

404-410

equivalent to [G]?

         

bull

2:36 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



I would like to simulate a 404 to certain User-agents although a file is still existent. For HTTP 1.1, I use

RewriteCond %{HTTP_USER_AGENT} ^Foo
RewriteCond %{REQUEST_URI} ^/file
RewriteRule .* - [G]

Is there any equivalent to [G] for a 404? Or another possibility? (file needs to remain on server) How risky is it to give a 410 for HTTP 1.0 requests?

Regards

jdMorgan

3:44 pm on Aug 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no [G] equivalent for 404. You could, however, simpy rewrite the requests internally to a non-existent file in order to generate a 404.

Don't return a 410 to an HTTP/1.0 client -- The client won't know what to do with it, because 410 wasn't defined until HTTP/1.1. That said, some clients which advertise as HTTP/1.0 are actually HTTP/1.1 compatible. One example is GoogleBot. The easiest way to determine a true HTTP/1.0 client is that it will not provide a Host header in the HTTP request; Just test HTTP_HOST, and if blank, use HTTP/1.0 protocol:


# Respond with 410-Gone to HTTP/1.1 requests for removed resources, else let them 404
RewriteCond %{HTTP_HOST} .
RewriteCond %{REQUEST_URI} ^/(announce¦mat¦sp_event¦whatsnew¦weather)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/(contact/¦poll4-99/)
RewriteRule .* - [G]

Jim

bull

7:32 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



Thank you Jim.

Testing revealed that Slurp is in fact HTTP 1.1 compatible as

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_USER_AGENT} Slurp
RewriteRule (.*)oldfilepatter$ - [G]

still returned it a 410. I nevertheless decided to give it a 404 via the method you suggested.