【问题标题】:Apache httpd block spam urls?Apache httpd 阻止垃圾邮件网址?
【发布时间】:2015-07-24 19:24:10
【问题描述】:

我正在使用 Apache httpd。我启用了 apache 的 rewrite 模块。我需要阻止一些网址(推荐垃圾邮件)。我有权编辑httpd.conf 文件。下面的语法是否正确以阻止多个 url?

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

【问题讨论】:

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


    【解决方案1】:

    我不是专家,但我认为:

    • RewriteCond 中的. 需要转义
    • 除了最后的RewriteCond 之外,你还需要OR 标志
    • RewriteRule 上的 L 标志有助于提高性能
    • 如果您使用捕获组,您还将阻止子域

    所以,我想你会想要这样的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多