Apache httpd阻止垃圾邮件网址?

时间:2015-05-13 13:15:24

标签: apache web-applications webserver load-balancing httpd.conf

我正在使用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>

1 个答案:

答案 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>