|
|
看到这样的一篇文章,很感兴趣,但对rewrite部分不太懂,不知高手能否详细解释一下?
使用独立的虚拟主机配置文件
当你修改vhost.map的时候,不需要重新启动Apache
这样的布局利用了 mod_rewrite 的高级特性, 在独立的虚拟主机配置文件中转换。如此可以更为灵活,但需要较为复杂的设置。
vhost.map 文件包含了类似下面的内容:
- http://www.customer-1.com/ /www/customers/1
- http://www.customer-2.com/ /www/customers/2
- #......
- http://www.customer-n.com/ /www/customers/N
复制代码
http.conf 包含了:
- RewriteEngine on
- RewriteMap lowercase int:tolower
- # 定义映像文件
- RewriteMap vhost txt:/VHOST.map的路径/vhost.map
- # 和上面的例子一样,处理变名
- RewriteCond %{REQUEST_URI} !^/icons/
- RewriteCond %{REQUEST_URI} !^/cgi-bin/
- RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
- # 这里做基于文件的重新映射
- RewriteCond ${vhost:%1} ^(/.*)$
- RewriteRule ^/(.*)$ %1/docs/$1
- RewriteCond %{REQUEST_URI} ^/cgi-bin/
- RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
- RewriteCond ${vhost:%1} ^(/.*)$
- RewriteRule ^/(.*)$ %1/cgi-bin/$1
复制代码 |
|