LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 902|回复: 4

真心求apache rewrite规则一例

[复制链接]
发表于 2006-6-21 20:02:07 | 显示全部楼层 |阅读模式
debian sarge + apache 2,apache 2 中 DocumentRoot /var/www。

在 /home 下有多个目录,如 ak47,miki (非系统用户名,只是普通的目录名)等。

请问:(不用考虑dns,已配置好)

如何实现用 http://ak47.example.com 来访问 /home/ak47/public_html/index.html?

用 http://miki.example.com/cgi-bin/ 访问 /home/miki/public_html/cgi-bin/index.cgi
发表于 2006-6-22 09:03:49 | 显示全部楼层
这个就是apache的虚拟主机呀.
回复 支持 反对

使用道具 举报

发表于 2006-6-22 15:52:30 | 显示全部楼层
很简单的虚拟主机配置,通常在httpd.conf.example文件末尾有说明。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-6-22 17:52:02 | 显示全部楼层
谢谢楼上两位!

请其他兄弟看清楚标题再回帖,谢谢~~~~~~
回复 支持 反对

使用道具 举报

发表于 2006-6-22 21:16:01 | 显示全部楼层
apache 手册里有下面一段:
Virtual User Hosts
Description:
Assume that you want to provide www.username.host.domain.com for the homepage of username via just DNS A records to the same machine and without any virtualhosts on this machine.

Solution:
For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests which contain a Host: HTTP header we can use the following ruleset to rewrite http://www.username.host.com/anypath internally to /home/username/anypath:

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2

把上边几行稍微修改一下就行了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表