APACHE邦定多域名不用重新启动的原理和方法

编辑httpd.conf
在最后加上


NameVirtualHost *

 1<virtualhost *="">   
 2rewriteengine on   
 3rewritecond %{HTTP_HOST} [^.]+\\.alibaba\\.uni\\.cc $   
 4rewriterule ^(.+) %{HTTP_HOST} $1 [C]   
 5rewriterule ([^.]+)\\.alibaba\\.uni\\.cc(.*) / $1 $2   
 6ServerAdmin  [email protected]    
 7DocumentRoot /www   
 8ServerName alibaba.uni.cc   
 9ErrorLog logs/alibaba.uni.cc-error_log   
10CustomLog logs/alibaba.uni.cc-access_log common   
11</virtualhost>

http://username.alibaba.uni.cc 对于username的主页请求转换为对 http://alibaba.uni.cc/username 的请求
---- 对于HTTP/1.1的请求包括一个Host: HTTP头,我们能用下面的规则集重写 http://username.alibaba.uni.cc/anypath 到/home/username/anypath。
注: “rewritecond”表明是条件重写规则,当满足后面定义的条件后才会应用下面的重写规则,“rewritecond”有各种变量,请查阅相关文档。

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus