您的位置:首页 > 运维架构 > Apache

apache禁止指定user_agent和禁止解析php

2015-07-28 20:15 661 查看
<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*chrom* [NC]
RewriteRule .* - [F]
</IfModule>

测试:[root@www ~]# curl -x127.0.0.1:80 www.test.com/forum.php(会提示<title>403 Forbidden</title>)

[root@www ~]# curl -x127.0.0.1:80 www.test.com/adkljh(也是403)
[root@www ~]# curl -x192.168.137.2:80 www.test.com/asdfg(也是403)
现在把curl那行注释,[root@www ~]# curl -x192.168.137.2:80 www.test.com/asdfg(会提示404)
[root@www ~]# curl -x192.168.137.2:80 www.test.com/forum.php -I(会提示200)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息