带有 3 个域的 WordPress LAMP。两个域按预期工作。一个域重定向到其他域之一

带有 3 个域的 WordPress LAMP。两个域按预期工作。一个域重定向到其他域之一

我已经成功安装并运行 Mint 19.1;Apache 2.4;PHP 7.2;phpmyadmin、Wordpress 5.1.1。

  • 站点 1 工作正常
  • 站点 2 在没有警告的情况下重定向到站点 1
  • 站点 3 工作如预期

站点 2 唯一看起来不同的是,顶级域名是 .US,而不是 .com

  • 我在 /var/www/site1.com/html 中有 site1.com
  • 我在 /var/www/site2.us/html 中有 site2.us
  • 我在 /var/www/site3.com/html 中有 site3.com

我有 /etc/apache2/sites-available/ site1.conf、site2.conf 和 site3.conf 文件,当我使用 A2ensite 启用每个站点配置文件时,这些文件会迁移到 /etc/apache2/sites-enabled/。我打算在解决此问题后将它们迁移到 HTTPS。

编辑显示 .conf 文件

站点 1

<VirtualHost *:80>  
   ServerName site1.com  
   Redirect permanent / https://site1.com/  
</VirtualHost>  

<VirtualHost *:443>  
        Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"  
        Header always append X-Frame-Options SAMEORIGIN  
        Header set X-XSS-Protection "1; mode=block"  
        ServerAdmin [email protected]  
        ServerName site1.com  
        ServerAlias www.site1.com  
        DocumentRoot /var/www/site1.com/html  
        ErrorLog ${APACHE_LOG_DIR}/error.log  
        CustomLog ${APACHE_LOG_DIR}/access.log combined  
        SSLEngine on  
        SSLCertificateFile  /etc/apache2/ssl/site1.com.crt  
        SSLCertificateKeyFile /etc/apache2/ssl/site1.com.key  
        SSLCertificateChainFile /etc/apache2/ssl/site1.com.intermediate.crt  
        SSLCipherSuite HIGH:!MEDIUM:!aNULL:!MD5:!RC4  
        SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire  
        <FilesMatch "\.(cgi|shtml|phtml|php)$">  
                SSLOptions +StdEnvVars  
        </FilesMatch>  
        <Directory /usr/lib/cgi-bin>  
                SSLOptions +StdEnvVars  
        </Directory>  
        <Directory /var/www/site1.com/html/>  
                AllowOverride All  
        </Directory>  
        RewriteEngine On  
        RewriteCond %{THE_REQUEST} !HTTP/1.1$  
        RewriteRule .* - [F]  
        ServerSignature Off  

</VirtualHost>  

站点2

<VirtualHost *:80>  
   ServerName site2.us  
   Redirect permanent / https://site2.us/  
</VirtualHost>  

<VirtualHost *:443>  
        Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"  
        Header always append X-Frame-Options SAMEORIGIN  
        Header set X-XSS-Protection "1; mode=block"  
        ServerAdmin [email protected]  
        ServerName site2.us  
        ServerAlias www.site2.us  
        DocumentRoot /var/www/site2.us/html  
    ErrorLog ${APACHE_LOG_DIR}/error.log  
    CustomLog ${APACHE_LOG_DIR}/access.log combined  
    SSLEngine on  
    SSLCertificateFile  /etc/apache2/ssl/site2.us.crt  
    SSLCertificateKeyFile /etc/apache2/ssl/site2.us.key  
    SSLCertificateChainFile /etc/apache2/ssl/site2.us.intermediate.crt  
    SSLCipherSuite HIGH:!MEDIUM:!aNULL:!MD5:!RC4  
    SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire  
    <FilesMatch "\.(cgi|shtml|phtml|php)$">  
            SSLOptions +StdEnvVars  
    </FilesMatch>  
    <Directory /usr/lib/cgi-bin>  
            SSLOptions +StdEnvVars  
    </Directory>  
    <Directory /var/www/site2.us/html/>  
            AllowOverride All  
    </Directory>  
        RewriteEngine On  
        RewriteCond %{THE_REQUEST} !HTTP/1.1$  
        RewriteRule .* - [F]  
        ServerSignature Off  

</VirtualHost>  

站点3

<VirtualHost *:80>  
   ServerName site3.com  
   Redirect permanent / https://site3.com/  
</VirtualHost>  

<VirtualHost *:443>  
        Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"  
        Header always append X-Frame-Options SAMEORIGIN  
        Header set X-XSS-Protection "1; mode=block"  
        ServerAdmin [email protected]  
        ServerName site3.com  
        ServerAlias www.site3.com  
        DocumentRoot /var/www/site3.com/html  
        ErrorLog ${APACHE_LOG_DIR}/error.log  
        CustomLog ${APACHE_LOG_DIR}/access.log combined  
        SSLEngine on  
        SSLCertificateFile  /etc/apache2/ssl/site3.com.crt  
        SSLCertificateKeyFile /etc/apache2/ssl/site3.com.key  
        SSLCertificateChainFile /etc/apache2/ssl/site3.com.intermediate.crt  
        SSLCipherSuite HIGH:!MEDIUM:!aNULL:!MD5:!RC4  
        SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire  
        <FilesMatch "\.(cgi|shtml|phtml|php)$">  
                SSLOptions +StdEnvVars  
        </FilesMatch>  
        <Directory /usr/lib/cgi-bin>  
                SSLOptions +StdEnvVars  
        </Directory>  
        <Directory /var/www/site3.com/html/>  
                AllowOverride All  
        </Directory>  
        RewriteEngine On  
        RewriteCond %{THE_REQUEST} !HTTP/1.1$  
        RewriteRule .* - [F]  
        ServerSignature Off  

</VirtualHost>  

** /var/www/site2.us/html/.htacess **

# BEGIN WordPress  
<IfModule mod_rewrite.c>  
RewriteEngine On  
RewriteBase /  
RewriteRule ^index\.php$ - [L]  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule . /index.php [L]  
</IfModule>  

答案1

清理并重启路由器和电缆调制解调器后,这种奇怪的现象就消失了。我推测路由器缓存了某些错误的东西。

相关内容