1、编辑虚拟主机配置文件
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
2、在rewite模板添加参数
修改rewrite模板条件将以下模板
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST] ^www.aaa.com$
RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]
修改为:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST] ^www.aaa.com$
RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*chrome* [NC]
RewriteRule .* - F
</IfModule>
3、使用curl 和chrome浏览器测试可否访问
curl -x127.0.0.1:80 -I www.test.com/admin.php
HTTP/1.1 403 Forbidden
Date: Wed, 25 May 2016 09:24:54 GMT
Server: Apache/2.2.31 (Unix) PHP/5.4.36
Content-Type: text/html; charset=iso-8859-1
(说明curl不可访问)
本文出自 “愺艮搥豩” 博客,请务必保留此出处http://riverxyz.blog.51cto.com/533303/1783102
原文地址:http://riverxyz.blog.51cto.com/533303/1783102