Web-Server

錯誤重定向到 www.www2.example.de 的原因是什麼

  • May 27, 2021

我為我們的主要網站設置了一個測試伺服器www.example.com

我將 apache-sites-config 設置為www2.example.com.

我刪除了.htaccess/ 調整它以保存基本的 wordpress 條目。

我禁用了瀏覽器的自動完成功能。

當我進入時,www2.example.com我被重定向並永久移動到www.www2.example.com.

當我進入時,192.168.0.1我被重定向到www.www2.example.com.

有人可以告訴錯誤可能在哪裡嗎?

.htaccess:

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

sites-config for the first vHost:

<VirtualHost *:80>
    Protocols h2 http/1.1
    ServerAdmin info@example.de
    DocumentRoot /var/www/html/
    ServerName www2.example.de
    ServerAlias www2.example.de

    <Directory /var/www/html>
       Options -Indexes +FollowSymLinks +MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


<VirtualHost *:443>
       ServerAdmin info@example.de
       Protocols h2 h2c http/1.1
       DocumentRoot /var/www/html/
       ServerName www2.example.de
       ServerAlias www2.example.de

       # added 01.04.2019 BEGINN
       <Directory /var/www/html>
               Options -Indexes +FollowSymLinks
               AllowOverride all
               Order allow,deny
               allow from all
       </Directory>
       # added 01.04.2019 END
       <Directory /var/www/html/>
         Options -Indexes +FollowSymlinks
         AllowOverride All
         Require all granted
        allow from all
       </Directory>
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
       SSLEngine off
</VirtualHost>
</IfModule>

sites-config for second vHost

<VirtualHost *:80>
    Protocols h2 http/1.1
    ServerAdmin info@example.de
    DocumentRoot /var/www/html1/example2/
    ServerName www2.example2.eu
    ServerAlias www2.example2.eu

    <Directory /var/www/html1/example2>
       Options -Indexes +FollowSymLinks +MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The request- and response-header for www2.example.de

Connection:     Keep-Alive
Content-Length: 236
Content-Type:   text/html; charset=iso-8859-1
Date:           Wed, 26 May 2021 10:41:46 GMT
Expires:        Wed, 26 May 2021 10:42:46 GMT
Keep-Alive:     timeout=5, max=100
Location:       https://www.www2.example.de/
Server:         Apache


Accept:         text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:de,en-US;q=0.7,en;q=0.3
Cache-Control:  no-cache
Connection:     keep-alive
DNT:            1
Host:           www2.example.de
Pragma:         no-cache
Upgrade-Insecure-Requests:  1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

SNI 將請求發送到 Live-Server 而不是 test-server。Live-Server 有重寫規則。

您應該檢查 WordPress 站點 URL 設置。如果站點 URL 與目前虛擬主機主機名不匹配,WordPress 會向站點 URL 發送 301 重定向。

引用自:https://serverfault.com/questions/1064734