【发布时间】:2012-03-22 22:53:27
【问题描述】:
在我的 Windows 7 中一切正常。
问题是当我将 domain1.com 添加为 VirtualHost 时,localhost 的 DocumentRoot 会更改为 VirtualHost 的 DocumentRoot。
例如: 当我访问http://localhost 时,我为 domain1.com 指定的 DocumentRoot 被打开,而不是 httpd.conf 中指定的那个。
我的 httpd-vhosts.conf 文件是:
NameVirtualHost 127.0.0.1:80
NameVirtualHost domain1.com:80
<VirtualHost domain1.com:80>
<Directory "e:/program files/apache/htdocs/domain1.com">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName domain1.com
ServerAlias domain1.com
ScriptAlias /cgi-bin/ "e:/program files/apache/htdocs/domain1.com/cgi-bin/"
DocumentRoot "e:/program files/apache/htdocs/domain1.com"
ErrorLog "E:/Program Files/apache/logs/domain1.com.err"
CustomLog "E:/Program Files/apache/logs/domain1.com.log" combined
</VirtualHost>
我的主机文件:
127.0.0.1 domain1.com
我的 httpd.conf 文件:
DocumentRoot "e:/program files/apache/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "e:/program files/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
我知道一种解决方案是添加 VirtualHost,ServerName 为 127.0.0.1 或 localhost,但我避免这样做。
我可以将 httpd.conf 中指定的 localhost 的 DocumentRoot 设为默认吗?
如果您需要更多信息,请告诉我。
谢谢, 吉格。
【问题讨论】:
标签: apache localhost virtualhost document-root hosts-file