apache学习笔记(访问控制|禁止解析|禁止指定user_agent)
访问控制
[root@tyrr apache2]# vim conf/extra/httpd-vhosts.conf
...
<Directory "/data/www">
AllowOverride None
Options None
Order allow,deny
Allow from all
Deny from 1.1.1.1
</Directory>:
禁止解析指定目录下的php文件
[root@tyrr apache2]# vim conf/extra/httpd-vhosts.conf
...
<Directory /data/www/data>
php_admin_flag engine off
<filesmatch "(.*)php">
Order deny,allow
Deny from all
Allow from 127.0.0.1
</filesmatch>
</Directory>
Apache 禁止指定user_agent
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.aaa.com$
RewriteRule ^/(.*)$ http://www.bbb.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*chr0me* [NC]
RewriteRule .* - [F]
</IfModule>