情况:将旧 WordPress 站点移至新域;相同的固定链接结构,301'd $1
在移动前不久,标签已被清理;从2000多个标签减少到十几个标签;尽管这些标签是在网站上合并的,但显然,许多 404 错误的出现是因为许多旧标签已在网站上使用多年,并在互联网上广泛建立索引。
- 即(/tag/frank-sinatra/ 或 /tag/tony-bennett/ 合并并重定向到 /tag/singers/)
我一直在通过 404 重定向插件 http://wordpress.org/extend/plugins/404-redirected/(记录并允许创建重定向)、Google 网站管理员工具数据(报告 404/抓取错误...)、损坏的链接检查器 http://wordpress.org/extend/plugins/broken-link-checker/ 并将重定向和 mod_rewrites 添加到我的 htaccess 中,因为每个解决方案似乎都是最经济的。
我的永久链接/规范网址结构 (/%postname%/) 使用尾部斜杠,即。 /post-or-page-name/ 或 /tag/tag-name/ 或 /category/category-name/
也就是说,这是我遇到的一个问题,我无法使用重定向 / mod_rewrite 正则表达式来解决自己:
Wordpress 自动重定向页面、帖子、标签、类别,缺少尾随斜杠,我已经创建了大量重定向,但从旧标签到新标签,但最近我遇到了很多404 是针对缺少尾部斜杠的旧标签 url 请求,其中大部分我已经修复为带有尾部斜杠的 url。即
- /tag/frank-sinatra/ 301 --> /tag/singers/ = 200 Success
- /tag/frank-sinatra = 404 Not Found
在将尾部斜杠强制到 URL 末尾以便重定向之前,它们会被 404 处理,
除了此之外还有其他解决方案吗为每个缺少尾部斜杠的旧标签网址创建单独的 301?
我不得不相信这一定是一个非常常见的问题,但到目前为止我还没有找到明智的工作解决方案!
感谢那些比我更有知识并且足够慷慨地分享解决方案的人:)
Situation: moved old WordPress site to new domain; same permalink structure, 301'd $1
Shortly before the move, the tags had been cleaned up; reduced from over 2000 tags to a dozen or so tags; altho the tags were merged on-site, obviously, lots of 404's began as many of those old tags had been used on the site for years and widely indexed all over the internet.
- i.e. (/tag/frank-sinatra/ or /tag/tony-bennett/ merged and redirected to /tag/singers/)
I have been redirecting 404's as they occur via a combination of 404 Redirected Plugin http://wordpress.org/extend/plugins/404-redirected/ (logs and allows to create redirections), Google Webmaster Tools data (reports 404's / crawl errors...), Broken Link Checker http://wordpress.org/extend/plugins/broken-link-checker/ and adding redirects and mod_rewrites to my htaccess as each solution seems most economical.
My permalink / canonical url structure (/%postname%/) uses a trailing slash, ie. /post-or-page-name/ or /tag/tag-name/ or /category/category-name/
That said, here is a problem I am presented with that I have been unable to solve myself with a redirection / mod_rewrite regex:
Wordpress automatically redirects pages, posts, tags, categories missing the trailing trailing slash and I have created a considerable number of redirections BUT from the old tags to the new tags but lately I have encountered a slew of 404's for old tag url requests that are missing the trailing slash, most of which I have already fixed as urls with a trailing slash. i.e.
- /tag/frank-sinatra/ 301 --> /tag/singers/ = 200 Success
- /tag/frank-sinatra = 404 Not Found
They are being 404'd before a trailing slash can be forced to the end of the url so they can be redirected
Is there a solution for this other than creating individual 301's for each old tag url missing the trailing slash?
I have to believe this must be a pretty common problem but the work smart solution has eluded me so far!
Thanks those more knowledgeable than myself and generous enough to share a solution :)
发布评论
评论(2)
如果所有 URL 都以尾部斜杠结尾,那么解决此问题的一种方法是重定向那些没有尾部斜杠的 URL。这将导致 2 301,但这比 404 更好。
为此,请将以下内容添加到站点根目录中的
.htaccess
文件中。确保这些规则出现在其他现有规则之前。如果尾部缺少斜杠的 URL 都是标签 URL,则将最后一条规则更改为
If all of your URLs end in a trailing slash, then one way to address this is to redirect those that do not have one. This will result in 2 301's, but that is better than a 404.
To do this add the following to the
.htaccess
file in the root directory of your site. Make sure these rules appear before other existing rules.If the URLs missing a trailing slash are all tag URLs, then change the last rule to
另一种方法是使用 ?在您的个人重定向中使尾部斜杠成为可选。
RewriteRule ^/tag/frank-sinatra/?$ /tag/singers/
Another way to do this is to use a ? in your individual redirects to make the trailing slash optional.
RewriteRule ^/tag/frank-sinatra/?$ /tag/singers/