0

Is it possible to simplfy these RewriteRules? I've hundreds of similar entries in my .htaccess file and it seems not to be the best way to set a 410 Header.

RewriteRule ^pageID_9363511.html - [G]
RewriteRule ^pageID_9363511_2.html - [G]
RewriteRule ^ci_8819019/thumb_11725326.JPG - [G]
…
…

Thank you

gearsdigital
  • 13,915
  • 6
  • 44
  • 73
  • 1
    Why are you doing this anyway? What's wrong with just letting the server send a 404 as normal? – noodl Nov 13 '10 at 11:54

2 Answers2

1

You could use a rewrite map like this:

pageID_9363511.html -
pageID_9363511_2.html -
ci_8819019/thumb_11725326.JPG -

Then you lookup the requested URI path like this:

RewriteCond ${gone:$0} =-
RewriteRule .+ - [G]

The only simplification is that you don’t need the repetitive RewriteRule and [G]. And with a rewrite map of the type dbm you could even have an access time of O(1) instead of O(n).

Gumbo
  • 643,351
  • 109
  • 780
  • 844
0

Get rid of all those rewritrules and say:

ErrorDocument 404 /404.html

Now just make a 404.html file and it will send all missing files to there. The 410 error message is rarely if ever shown in practice as it refers to a missing server as opposed to a missing file: http://www.checkupdown.com/status/E410.html

J V
  • 11,402
  • 10
  • 52
  • 72