douyiyi5284 2017-07-18 06:46
浏览 65
已采纳

Wordpress重定向错误

I'm currently using Wordpress 4.8 with permalink structure of https://www.example.com/%category%/%postname%/. I also use Redirection plugin. After awhile, I decided to move my wordpress installation from Root to Subdirectory using this tutorial from official wordpress.org. I followed exactly like first method. It works but from time to time I receive a lot of 404 error log in Redirection plugin log and Google Search Console log.

I created subdirectory for wordpress using same name with domain name. Assume my domain is https://www.example.com. I created subdirectory name of www.example.com. Reason because I have multiple addon domains which I installed wordpress in similar way. Only this main domain have problem.

PROBLEM: I often receive 404 errors log in Redirection plugin log and Google Search Console. Assume I have a page of overflow then my URL error look like this https://www.example.com/www.example.com/category/overflow/ instead of https://www.example.com/category/overflow/ and this is happened everyday on many URL's even newer posts. With exception of my index.php where my https://www.example.com/www.example.com/index.php always redirect to https://www.example.com/ without any problem and no error logs.

.HTACCESS on Root

# 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 on Subdirectory

<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>

QUESTION: How do I add a wildcard redirects which will redirect anything matching condition www.example.com/www.example.com to www.example.com

For example:

  1. https://www.example.com/www.example.com/pageA/ to https://www.example.com/pageA/
  2. https://www.example.com/www.example.com/Category1/pageB/ to https://www.example.com/Category1/pageB/
  3. https://www.example.com/www.example.com/Category2/pageC/ to https://www.example.com/Category2/pageC/ and so on.

I'll be honest. I do know how to redirect oldPage to newPage but seems this is out of my knowledge. I tried many tutorial on google and redirect generator etc but still I receive 404 error logs of that kind. Please help me. Thank in advance.

  • 写回答

1条回答 默认 最新

  • dtn36013 2017-07-18 10:35
    关注

    You can try this plugin 301 redirect. it is useful to redirection old URL to new URL

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件