【发布时间】:2021-01-30 17:00:57
【问题描述】:
在 apache (windows 10) 上设置 vHost 时,一切正常 - 而不是 DocumentRoot。 它仍然是 htdocs 目录,而不是我在 httpd-vhosts.conf 中设置的目录:
Listen 80
<VirtualHost *:80>
ServerAdmin your@email.com
DocumentRoot "C:\Test"
ServerName www.test.test
<Directory "C:\Test">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我还将域添加到 C:\Windows\System32\drivers\etc> 的 hosts 文件夹中。所以这部分工作正常:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 www.test.test
就在更改 httpd.conf 文件中的 documentRoot 时,如:
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "C:\Test"
<Directory "C:\Test">
...
它似乎工作。但这不是一个合适的解决方案...
【问题讨论】:
-
我觉得不错。理论上路径应该使用正斜杠,但实际上反斜杠可以正常工作。你使用的是 Apache/2.4,实际加载
httpd-vhosts.conf并在进行更改后重新启动服务? -
@ÁlvaroGonzález “实际加载 httpf-vhosts.conf”是什么意思?之后我重新启动了一切。连电脑...
标签: apache virtualhost vhosts