How to Simplify .htaccess Rewriterule
Is it possible to simplfy these RewriteRules? I've hundreds of similar entries 开发者_StackOverflow社区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
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).
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
精彩评论