How can I apply a rule with mod_rewrite only开发者_Go百科 if a file is directly accessed? (No referrer is detected)
I have this so far but it does not seem to work:
RewriteCond %{HTTP_REFERER} !^(.*)
If you're looking to match an empty string, it's better to use the equality operator than a regex. So, whilst Gumbo's answer will work, it would be better to use
RewriteCond %{HTTP_REFERER} !=""
As .*
matches anything (even the empty string), this condition will never be fulfilled. Either use !^(.+)
or simply ^$
:
RewriteCond %{HTTP_REFERER} !^$
精彩评论