如果“www”,则站点重定向到子域。未输入 URL

如果“www”,则站点重定向到子域。未输入 URL

我正在 Ubuntu 20.04.5 LTS (GNU/Linux 5.16.11-051611-generic x86_64) 上运行 WordPress 网站,我们将其称为 myDomain.com。

我有一个 .NET Core 应用程序部署在同一服务器域名如:在端口上运行的 myApp.myDomain.com5003

如果你没有www.myDomain.com缓存在浏览器中并且您在地址栏中输入“myDomain.com”,您将被重定向到 myApp.myDomain.com 而不是www.myDomain.com

我对 WordPress 中的 .htaccess 文件进行了大量更改,但它没有解决问题,因此我认为这是我的 .NET 应用程序的 Apache .conf 文件(应用程序的 VirtualHost 配置,myApp.myDomain.com) :

<VirtualHost *:*>
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>


<VirtualHost *:80>
    ProxyPreserveHost On


    ProxyPass / http://myDomainIP:5003/
    ProxyPassReverse / http://myDomainIP:5003/
    ServerName myApp.myDomain.com
    ServerAlias *.myApp.myDomain.com


    ErrorLog ${APACHE_LOG_DIR}myApp-error.log
    CustomLog ${APACHE_LOG_DIR}myApp-access.log common
</VirtualHost>


<VirtualHost *:443>


    ServerName myApp.myDomain.com

    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
    SSLEngine on
    SSLCertificateFile /etc/ssl/crt/myCert.crt
    SSLCertificateKeyFile /etc/ssl/crt/myWildcardCert.key
    SSLCertificateChainFile /etc/ssl/crt/myCertFile.crt
    ErrorLog ${APACHE_LOG_DIR}httpsmyApp-error.log
    CustomLog ${APACHE_LOG_DIR}httpsmyApp-access.log common


    ProxyPreserveHost On


    ProxyPass / http://myDomainIP:5003/
    ProxyPassReverse / http://myDomainIP:5003/
</VirtualHost>

站点 myDomain.com 的 VirtualHost 配置:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName myDomain.com
ServerAlias www.myDomain.com
Redirect / https://www.myDomain.com/

DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</VirtualHost>


<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName www.myDomain.com


Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
SSLEngine on

SSLCertificateFile /etc/ssl/crt/myCert.crt
SSLCertificateKeyFile /etc/ssl/crt/myWildcardCert.key
SSLCertificateChainFile /etc/ssl/crt/myCertFile.crt
</VirtualHost>

有什么想法这是否可能是发生此重定向的原因?

提前致谢

相关内容