我在一台服务器上托管两个网站。每个都定义了自己的 VirtualHost。第一个站点运行良好,但是当我尝试访问第二个站点时,我被重定向到第一个站点。就像 Apache 无法通过 ServerName 识别正确的 VirtualHost 并将我重定向到默认(第一个)站点。
是否有日志或其他东西可以让我看到 Apache 在处理我的请求时正在采取哪些步骤?当它试图找到匹配的 VirtualHost 时,它是否会在任何地方记录它使用的 ServerName?
更新:
我为我的第二个站点的子域添加了一个 VirtualHost 部分,并且有效。当我在浏览器中输入“interface.domain.com”时,它会从在 8501 端口中运行的正确应用程序服务器呈现页面。但是当我尝试“www.domain.com”时,它会重定向到我的第一个站点。
下面是我的第二个站点的虚拟主机文件。
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /home/domain/current/public
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://localhost:8501/$1 [P]
</VirtualHost>
<VirtualHost *:80>
ServerName interface.domain.com
DocumentRoot /home/domain/current/public
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://localhost:8501/$1 [P]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 1.2.3.4. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration: …
Run Code Online (Sandbox Code Playgroud)