Apache 虚拟服务器 httpd-vhosts 未记录的问题

Apache 虚拟服务器 httpd-vhosts 未记录的问题

我阅读了 Apache 文档中有关 https-vhosts.conf 文件的内容,经过几个小时的尝试,终于自己解决了这个问题。情况如下:

我们有一个以 .ws 结尾的域名

显然您无法在 conf 文件中执行此操作。您必须使用 ? 通配符,否则它将不起作用。 * 通配符也不起作用。此外,在 ServerAlias 指令中,如果 ServerAlias 指令中的第一个条目不正确,则第一个条目之后的任何内容都将不起作用。

以下是无法正常工作的条目示例。请注意,anotherdomain.com 和 yetanotherdomain.com 将失败,因为 thedomain.ws 配置不正确:

<VirtualHost *:80>
DocumentRoot /opt/local/apache2/sites/ourdomain
ServerName www.thedomain.ws
ServerAlias thedomain.ws another domain.com yetanotherdomain.com
<Directory /opt/local/apache2/sites/ourdomain>
allow from all
</Directory>
</VirtualHost>

以下是我们的工作条目的一个示例:

<VirtualHost *:80>
DocumentRoot /opt/local/apache2/sites/ourdomain
ServerName www.thedomain.ws?
ServerAlias thedomain.ws? another domain.com yetanotherdomain.com
<Directory /opt/local/apache2/sites/ourdomain>
allow from all
</Directory>
</VirtualHost>

如果有这方面的文件证明,我肯定没有看到。

答案1

?据我所知,根本不是通配符——不在ServerAlias,而且绝对不在ServerName,它不支持任何类型的通配符。

在测试系统上,我看到了我所期望的行为 -ServerName test.ws运行良好,并且ServerName test.ws?从不将请求映射到该虚拟主机。

我估计您看到了其他问题 - 当您收到无效.ws?名称时,获取请求的虚拟主机实际上正在正确处理请求。请提供输出apachectl -S以及该输出中的任何相关虚拟主机配置。

相关内容