rewrite_URL虚拟主机

rewrite_URL虚拟主机

我用OpenBSD3.8自代Apache做WEB主机。WEB可访问  http;//obsd.xisu.edu.cn  主机名obsd,另建两个虚拟主机:wljs和wlzx  用mod_rewrite做URL rewrite ,可实验了几天不成功,虚拟主机PATH为:/home/www/wljs和/home/www/wlzx  在rc.conf里已设置为“-u”已解除chroot。现将Apache设置和错误信息贴出请众多高手给我指正。

NameVirtualHost 69.74.67.249

<VirtualHost 59.74.67.249>
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /var/www/htdocs
    ServerName obsd.xisu.edu.cn
</VirtualHost>

<VirtualHost 59.74.67.249>
    RewriteEngine on
    RewriteLog /tmp/log/rewrite.log
    RewriteLogLevel 0
    RewriteRule ^http://wlzx.xisu.edu.cn/(.*)$ http://obsd.xisu.edu.cn/$1
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/www/wlzx
    ServerName wlzx.xisu.edu.cn
</VirtualHost>

<VirtualHost 59.74.67.249>
    RewriteEngine on
    RewriteLog /tmp/log/rewrite.log
    RewriteLogLevel 0
    RewriteRule ^http://wljs.xisu.edu.cn/(.*)$ http://obsd.xisu.edu.cn/$1
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/www/wljs
    ServerName wlzx.xisu.edu.cn
</VirtualHost>

[Thu Mar 13 01:26:13 2003] [warn] VirtualHost 59.74.67.249:80 overlaps with VirtualHost 59.74.67.249:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Thu Mar 13 01:26:13 2003] [warn] VirtualHost 59.74.67.249:80 overlaps with VirtualHost 59.74.67.249:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Thu Mar 13 01:26:13 2003] [warn] NameVirtualHost 69.74.67.249:80 has no VirtualHosts
/usr/sbin/apachectl start: httpd could not be started
经过反复配置测试,非常感谢杨寿保教授的文章,我终于搞好了.非常感谢大家,现把配置文件帖出来.

options Indexes followsymlinks
rewriteengine on
RewriteMap  lowercase  int:tolower
RewriteCond  %{REQUEST_URI}  !^/cgi-bin/
RewriteCond  ${lowercase:%{HTTP_HOST}}  !^obsd\.xisu\.org(\.*)$
RewriteCond  ${lowercase:%{HTTP_HOST}}  ^[a-z0-9-]+\.xisu\.org(\.*)$
RewriteRule  ^(.+)  ${lowercase:%{HTTP_HOST}}$1  [C]
RewriteRule  ^([a-z0-9])([a-z0-9])([a-z0-9])\.xisu\.org([\.]*)/(.*)  /home/member/$1$2/$2$3/$1$2$3/$5
RewriteRule  ^([a-z0-9])([a-z0-9])([a-z0-9]*)([a-z0-9])([a-z0-9])\.xisu\.org([\.]*)/(.*) /home/member/$1$2/$4$5/$1$2$3$4$5/$7

NameVirtualHost 192.168.3.9

<VirtualHost 192.168.3.9>
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /var/www/htdocs
    ServerName obsd.xisu.org
</VirtualHost>

<VirtualHost i192.168.3.9>
    RewriteEngine on
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/member/ks/k2/ksk2
    ServerName ksk2.xisu.org
</VirtualHost>

<VirtualHost 192.168.3.9>
    RewriteEngine on
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/member/gz/b2/gzb2
ServerName gzb2.xisu.org
</VirtualHost>

<VirtualHost i192.168.3.9>
    RewriteEngine on
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/member/ww/w2/www2
    ServerName www2.xisu.org
</VirtualHost>

<VirtualHost i192.168.3.9>
    RewriteEngine on
    ServerAdmin jin333@xisu.edu.cn
    DocumentRoot /home/member/jy/x2/jyjszx2
    ServerName jyjszx2.xisu.org
</VirtualHost>
不用重写是否可以?好象说重写不安全。
不错,参考参考