如何使用带有.htaccess的通配符禁止主机名

时间:2013-05-26 16:12:59

标签: .htaccess

我如何禁止pingdomtools的请求?

他们的主机名看起来像这样:

s464.pingdom.com

那么如何禁止所有以

结尾的主机名
pingdom.com

3 个答案:

答案 0 :(得分:1)

您可以使用重写规则。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*tumblr\.com [NC]
RewriteRule .* - [F]
</IfModule>

http://davidwalsh.name/block-domain

  • 注意:此块基于引用,可以被欺骗或完全遗漏。

更新:在执行反向DNS的服务器上,您可以尝试:

deny from .pingdom.com

https://httpd.apache.org/docs/2.0/mod/mod_access.html#allow

答案 1 :(得分:0)

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} somesite\.com [NC,OR]
RewriteRule .* - [F]

答案 2 :(得分:0)

好吧,因为禁止主机名并不容易,我只是禁止了用户代理:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Pingdom.com
RewriteRule ^(.*)$ http://go.away/

工作正常。