使用路径时,Apache 虚拟主机会加载错误页面

使用路径时,Apache 虚拟主机会加载错误页面

我在 Apache 服务器 (RedHat) 上设置了许多虚拟主机,它们在使用路径之前都运行正常。解释一下。

我有:

  • https://myserver1.com (默认站点)
  • https://myserver2.com
  • https://myserver3.com

但当用户访问其中任何一个网站时,他们都会得到正确的页面,并且 URL 会附加到 /PORTAL/STARTUP.php

但是如果用户将他们的页面加入书签,例如 https://myserver3.com/PORTAL/STARTUP.php ,他们将进入默认网站,但使用正确的 URL。

我错过了什么?

<VirtualHost *:443>
    DocumentRoot /var/www/html/myserver1
    ServerName myserver1. com
    ErrorLog logs/myserver1-error_log
    CustomLog logs/myserver1-access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/myserver2
    ServerName myserver2.com
    ErrorLog logs/myserver2-error_log
    CustomLog logs/myserver2-access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/myserver3
    ServerName myserver3.com
    ErrorLog logs/myserver3_error_log
    CustomLog logs/myserver3_access_log common
</VirtualHost>

更新

<VirtualHost 111.111.111.111:80>
        ServerAlias *
        RewriteEngine On
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</VirtualHost>

<VirtualHost 111.111.111.111:80>
        ServerAlias *
        RewriteEngine On
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</VirtualHost>

<filesMatch "\.(html|htm|js|css|png)$">
  FileETag None
  <ifModule mod_headers.c>
     Header unset ETag
     Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
     Header set Pragma "no-cache"
     Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  </ifModule>
</filesMatch>

Header set X-Permitted-Cross-Domain-Policies: "master-only"
Header always set X-Frame-Options SAMEORIGIN
Header set X-XSS-Protection: "1; mode=block"
Header set Access-Control-Allow-Origin "*"

<VirtualHost *:80>
    ServerName clientA.com
    DocumentRoot /var/www/html
    ErrorLog logs/clientA.com-error_log
    CustomLog logs/clientA.com-access_log common
</VirtualHost>

<VirtualHost *:443>
    ServerName clientB.com:443
    DocumentRoot /var/www/html
    Redirect / https://clientB.com/
    ErrorLog logs/clientB.error_log
    CustomLog logs/clientB.access_log common
</VirtualHost>

#<VirtualHost *:443>
   # DocumentRoot /var/www/html/clientC
    #ServerName www.clientC.com
    #ErrorLog logs/clientB.com-error_log
    #CustomLog logs/clientB.com-access_log common
#</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientD
    ServerName clientD.com
    ErrorLog logs/clientD.com-error_log
    CustomLog logs/clientD.com-access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientE
    ServerName clientE.com
    ErrorLog logs/clientD.com-error_log
    CustomLog logs/clientD.com-access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientF
    ServerName clientF.com
    ErrorLog logs/clientF.com_error_log
    CustomLog logs/clientF.com_access_log common
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot /var/www/html/clientG
  ServerName clientG.com
  ErrorLog logs/clientG_error_log
  CustomLog logs/clientG_access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientH
    ServerName clientH.com
    ErrorLog logs/clientH_error_log
    CustomLog logs/clientH_access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientI
    ServerName clientI.com
    ErrorLog logs/clientI_error_log
    CustomLog logs/clientI_access_log common
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/clientJ
    ServerName clientJ.com
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

<VirtualHost *:443>
    ProxyPreserveHost On
    ProxyPass / http://111.111.111.111/
    ProxyPassReverse / http://11.111.111.111/
    ServerName clientK.com
    ErrorLog logs/clientK_error_log
    CustomLog logs/clientK_access_log common
</VirtualHost>

然后上面的 vhost 条目继续通过 J 到达客户端

相关内容