开发者

Mod_Rewrite - If no referrer detected then do rule

开发者 https://www.devze.com 2023-02-07 13:04 出处:网络
How can I apply a rule with mod_rewrite only开发者_Go百科 if a file is directly accessed? (No referrer is detected)

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

精彩评论

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