我目前使用的Wordpress 4.8與永久鏈接結構https://www.example.com/%category%/%postname%/。我也使用Redirection插件。過了一段時間,我決定使用這個tutorial from official wordpress.org將我的wordpress安裝從根目錄移動到子目錄。我遵循第一種方法。它的工作原理,但我不時在重定向插件日誌和Google Search Console日誌中收到很多404錯誤日誌。WordPress的重定向錯誤
我爲wordpress創建的子目錄使用同名與域名。假設我的域名是https://www.example.com。我創建了子目錄名稱www.example.com。原因是因爲我有多個插件域,我以類似的方式安裝了wordpress。只有這個主域有問題。
問題: 我經常收到404錯誤登錄重定向插件日誌和Google Search Console。假設我有一個頁面溢出然後我的網址錯誤看起來像這個https://www.example.com/www.example.com/category/overflow/而不是https://www.example.com/category/overflow/這是每天發生在許多URL甚至更新的職位。除了我的index.php,我的https://www.example.com/www.example.com/index.php總是重定向到https://www.example.com/,沒有任何問題,也沒有錯誤日誌。在根
的.htaccess的子目錄
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/www.example.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ /www.example.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(/)?$ www.example.com/index.php [L]
</IfModule>
的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</IfModule>
# END HTTPS
# 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>
問題: 如何添加一個通配符重定向將重定向任何符合條件WWW .example.com/www.example.com到 www.example.com
例如:
- https://www.example.com/www.example.com/pageA/到https://www.example.com/pageA/
- https://www.example.com/www.example.com/Category1/pageB/到https://www.example.com/Category1/pageB/
- https://www.example.com/www.example.com/Category2/pageC/到https://www.example.com/Category2/pageC/等。
我說實話。我知道如何將oldPage重定向到新頁面,但似乎這是我的知識。我嘗試了很多關於谷歌和重定向生成器等的教程,但仍然收到了那種404錯誤日誌。請幫幫我。預先感謝。