我正在使用Apache httpd。我启用了apache的rewrite
模块。我需要阻止几个网址(引用垃圾邮件)。我有权编辑httpd.conf
文件。以下语法是否正确以阻止多个网址?
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine on
RewriteCond %{HTTP_REFERER} example.com [NC]
RewriteCond %{HTTP_REFERER} sample.com [NC]
RewriteCond %{HTTP_REFERER} somexxx.com [NC]
RewriteRule .* - [F]
</Directory>
答案 0 :(得分:0)
我不是专家,但我认为:
.
中的RewriteCond
需要转义OR
RewriteCond
个标记
L
上的RewriteRule
标记有助于提高性能所以,我想你会想要这样的东西:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine on
RewriteCond %{HTTP_REFERER} (example\.com) [NC,OR]
RewriteCond %{HTTP_REFERER} (sample\.com) [NC,OR]
RewriteCond %{HTTP_REFERER} (somexxx\.com) [NC]
RewriteRule .* - [F,L]
</Directory>