[英]301 redirects and wordpress pretty permalinks
I am moving from an old php based site to a new one based on wordpress. 我正从一个基于php的旧站点迁移到一个基于wordpress的新站点。 In the process we are getting rid of quite a few unnecessary pages.
在此过程中,我们摆脱了很多不必要的页面。
However some of the pages are showing on google, and I want to avoid 403 or 404 errors by using 301 redirects to pages now containing the same info on the new site. 但是,有些页面正在google上显示,我想通过使用301重定向到现在在新站点上包含相同信息的页面来避免403或404错误。
My current .htaccess shows: 我当前的.htaccess显示:
# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine Off
SetEnv DEFAULT_PHP_VERSION 53
DirectoryIndex index.cgi index.php
# 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>
# END WordPress
and I was wondering what the best way to do 301 redirects is? 我想知道执行301重定向的最佳方法是什么? putting them before or after the code just gives a 404 error.
将它们放在代码之前或之后只会产生404错误。
This should work; 这应该起作用;
redirect 301 /old/old.htm http://www.website.com/new.htm 重定向301 /old/old.htm http://www.website.com/new.htm
Putting a rule similar to this before the index.php rewrite rules should work: 在index.php重写规则之前放置一个与此类似的规则应该起作用:
RewriteRule ^(.*)$ http://newwebsite.com/$1 [R=301,L]
You can put a bunch of RewriteCond's before it to catch only those pages with issues. 您可以在其前面放一堆RewriteCond,以仅捕获那些有问题的页面。
For the specific case you posted in the comments, this rule works: 对于您在评论中发布的特定案例,此规则有效:
RewriteRule ^why-choose-us.* about-us [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.