PHPChina网友需求:123.badu.com 自动转向www.baidu.com/123 并且保持域名还是123.baidu.com
地址:http://bbs.phpchina.com/thread-169014-1-1.html
经过摸索,终于找到了实现方法,就是通过使用Apache的Rewrite和Proxy实现跨主机透明转发,不改变地址栏的URL网址。
下面是实现步骤:
1. 在123.baidu.com的.htaccess文件中开启重写规则:
RewriteEngine On
RewriteRule ^(.*)$ http://www.baidu.com/123/$1 [P,L]
2. 在Apache的配置文件中开启以下模块:
mod_rewrite.so
mod_proxy.so
mod_proxy_http.so
3. 重启Apache服务器,载入最新的配置。
转载自:http://hi.baidu.com/fising/blog/item/54fa5bafbd1840f0faed507e.html