不好意思,d:/data和k:/database是同一目录,是我放到CSDN的时候手误的问题。 9楼的意思是不是我下面设置的目录不能和这个相同?我试一下看,谢谢!还有下面这段是不是必须? <Directory "k:/database"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all</Directory>在这段之前还这么一段 <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all Satisfy all </Directory>
像你这种需求不是正好使用 vhost 吗LoadModule vhost_alias_module modules/mod_vhost_alias.so
VirtualDocumentRoot d:/database/%0
VirtualDocumentRoot d:/database/%0 这招用不起来哟。一加后面这句,就请求失败,APACHE就重启不了
<VirtualHost *>
RewriteEngine on
ServerAdmin [email protected]
DocumentRoot d:/data
ServerName all-sites RewriteCond d:/data/%{SERVER_NAME} -d
RewriteRule ^/(.+)$ d:/data/%{SERVER_NAME}/$1 [L]
RewriteRule ^.*$ /index.php [L]
</VirtualHost>如果你确定d:/data和k:/database下面是一样的话说明你其他配置有问题
9楼的意思是不是我下面设置的目录不能和这个相同?我试一下看,谢谢!还有下面这段是不是必须?
<Directory "k:/database">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None #
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all</Directory>在这段之前还这么一段
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
也要看 VirtualDocumentRoot d:/database/%0 中的 d:/database 目录是否存在
发现这个东西越来越有趣了,现在我有另一个方案来解决我的问题,具体如下,但里面些问题,大家给我看看,提点一下在下,多谢了。NameVirtualHost *
<VirtualHost *>
RewriteEngine on
ServerAdmin [email protected]
DocumentRoot k:/database#指定目录中有对应域名的-----OK
RewriteCond k:/database/%{SERVER_NAME} -d
RewriteRule ^/(.*)$ k:/database/%{SERVER_NAME}/$1 [L]#第一条规则不符合,那就用这条规则
#特定域名的二级,我想用新的规则-----为何不行?好像是找不到文件目录,错在哪里呢?
RewriteCond %{HTTP_HOST} ^\w+\.vvvwz\.com$
#将下面这一行注释掉也不行
RewriteRule ^(.+) k:/database/vvvwz.com/$1 [C]
RewriteRule ^(\w+)\.vvvwz\.com(.*) k:/database/vvvwz.com/$1$2 [L]#想把这个设置成默认,但用IP访问过来,也不行,是不是前面的没搞定的原因呢?
RewriteRule ^.*$ k:/database/vvvwz.com/index.php [L]
</VirtualHost>To:Mistruster 你说的问题我再试一下,可能是没有注释NameVirtualHost的原因。
放在前面试过了,也没有用。真郁闷有加。另外,重新试了一下这个。
你要检查mod_vhost_alias.so这个文件是否存在,路径是否正确,还有你把NameVirtualHost相关的东西先注释掉
也要看 VirtualDocumentRoot d:/database/%0 中的 d:/database 目录是否存在
发现还是不行。目录没问题,mod_vhost_alias.so这个文件也存在,NameVirtualHost相关的东西已经注释掉。
依然不能启动apache,注释VirtualDocumentRoot d:/database/%0 这个就可以启动,加上就不行。
to: EverybodyRewriteRule ^(.+) k:/database/vvvwz.com/$1 [C]
RewriteRule ^(\w+)\.vvvwz\.com(.*) k:/database/vvvwz.com/$1$2 [L] 这两句中,第一句是不是必要呢?我的目录结构如下:K:/
|--database/
| |--www.host1.com/
| |--www.host2.com/
| |--vvvwz.com/
| | |--bbs/
| | |--www/
利用RewriteMap来搞定路径问题,不过也有美中不足。
不过也贴出来跟大家分享NameVirtualHost *
<VirtualHost *>
RewriteEngine on
ServerAdmin [email protected]
DocumentRoot k:/database/# rewrite with map
#================
RewriteMap lowercase int:tolower
RewriteMap vhost txt:k:/rewrite.txt
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
#下面这一行的意思是,
#前部分:在vhost中查找域名,找到返回其后面的路径,否则就返回|后面的默认
#后部分:检测路径是否为匹配k开头的
RewriteCond ${vhost:%{SERVER_NAME}|k:/database/default} ^(k.*)$
RewriteRule ^/(.*)$ ${vhost:%{SERVER_NAME}|k:/database/default}/$1
</VirtualHost>
rewrite.txt
===============
www.host1.com k:/database/host1
www.host2.com k:/database/host2
www.vvvwz.com k:/database/vvvwz.com/www
bbs.vvvwz.com k:/database/vvvwz.com/bbs
但是这个又有新的问题,泛域名没折了,不是www开头的都会转到k:/database/default里去了,总不能每个都在rewrite.txt加一行吧。
真是郁闷,发现个好的,又有不足之处。大家看看有没有好方法解决这个泛域名问题呢?
比如:http://aaa.bbb.ccc.com
这个域名返回ccc.com就可以了,如此一来,rewrite.txt文件中的域名只留主体部分就OK了。
通过RewriteMap的方法,再加上这个的话,就完美解决泛域名的问题了。没人参与讨论的话,就只有结帐了