开发者

Mod_Rewrite - If no referrer detected then do rule

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} !^$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜