0

我正在使用Apache httpd。我啓用了Apache的rewrite模塊。我需要阻止一些網址(引用垃圾郵件)。我有權編輯httpd.conf文件。低於語法正確阻止多個網址?Apache httpd塊垃圾郵件網址?

<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

我不是專家,但我認爲:

  • RewriteCond需求.轉義
  • 你需要的所有OR標誌,但最終RewriteCond
  • 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>