Mass Virtual Hosting 到底怎么实现啊?捆饶已久

王朝厨房·作者佚名  2007-01-05
宽屏版  字体: |||超大  

Mass Virtual Hosting

Description:

The <VirtualHost> feature of Apache is nice and works great when you just have a few dozens virtual hosts. But when you are an ISP and have hundreds of virtual hosts to provide this feature is not the best choice.

Solution:

To provide this feature we map the remote webpage or even the complete remote webarea to our namespace by the use of the Proxy Throughput feature (flag [P]): ##

## vhost.map

##

www.vhost1.dom:80 /path/to/docroot/vhost1

www.vhost2.dom:80 /path/to/docroot/vhost2

:

www.vhostN.dom:80 /path/to/docroot/vhostN

##

## httpd.conf

##

:

# use the canonical hostname on redirects, etc.

UseCanonicalName on

:

# add the virtual host in front of the CLF-format

CustomLog /path/to/access_log "%{VHOST}e %h %l %u %t \"%r\" %>s %b"

:

# enable the rewriting engine in the main server

RewriteEngine on

# define two maps: one for fixing the URL and one which defines

# the available virtual hosts with their corresponding

# DocumentRoot.

RewriteMap lowercase int:tolower

RewriteMap vhost txt:/path/to/vhost.map

# Now do the actual virtual host mapping

# via a huge and complicated single rule:

#

# 1. make sure we don't map for common locations

RewriteCond %{REQUEST_URI} !^/commonurl1/.*

RewriteCond %{REQUEST_URI} !^/commonurl2/.*

:

RewriteCond %{REQUEST_URI} !^/commonurlN/.*

#

# 2. make sure we have a Host header, because

# currently our approach only supports

# virtual hosting through this header

RewriteCond %{HTTP_HOST} !^$

#

# 3. lowercase the hostname

RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$

#

# 4. lookup this hostname in vhost.map and

# remember it only when it is a path

# (and not "NONE" from above)

RewriteCond ${vhost:%1} ^(/.*)$

#

# 5. finally we can map the URL to its docroot location

# and remember the virtual host for logging puposes

RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]

:

按照上边做的,好象没有用,加不加都一样。

我用的是apache 1.3.17, 应该包含 rewrite模块了吧(重新启动httpd,不报错误,说明认识 rewriteengine等指令) 为什么 url rewrite 不起作用?

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有