Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Help understanding a rewritecond


lucy24 - 3:20 am on Dec 13, 2011 (gmt 0)


I'd modify both lines to

^-?$

because most blank referers and UAs aren't truly blank. They almost always come through as a single hyphen-- just like the one in your Rule.

Has anyone ever met a blank UA that took the trouble to send a referer? You can achieve pretty much the same thing in half the server time by only excluding blank UAs.

Now then. Some people will disagree with this, but I like to constrain rules as tightly as possible. The chances of a robot swinging by "cold" and demanding all your image files are, for most sites, vanishingly small. So you can express the "pattern" part of the Rule as, for example,

\.html$

(substituting your actual filename extension) instead of .* --with some further tweaks depending on whether directory indexes have already been added before the request reaches mod_rewrite. If they haven't, you also have to allow for requests ending in slash, or empty requests-- meaning your front page in mod_rewrite-speak.

The idea is that if someone is asking for pictures and stylesheets, they are either an authorized robot or someone who has already been allowed to land on a page, so there is no need to make the server continue evaluating conditions.


Thread source:: http://www.webmasterworld.com/apache/4397270.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com