重定向wordpress上的所有帖子 [英] Redirect all posts on wordpress

查看:99
本文介绍了重定向wordpress上的所有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将网站移到了新主机上,但是偶然地更改了永久链接.首先,我有一个/%postname%.html,并在移至新主机后将其更改为/%postname%/. 我已修复了永久链接,并且工作正常,除非Google抓取我的网站时google搜索结果返回404错误页面.

I moved my site to a new host but by accident permalink was changed. First i had a /%postname%.html and after moving to new host it got changed to /%postname%/ . I fixed the permalink and is working fine except when Google crawls my website google search results return 404 error pages.

我尝试了每个重定向插件,但没有任何效果.我想重定向 http://www.website.com/sample-post/ http://www.website.com/sample-post.html

I tried every redirect plugin and nothing is working. I want to redirect every post that is http://www.website.com/sample-post/ to http://www.website.com/sample-post.html

我无法添加每一个帖子,因为大约有10万个帖子.

I can not add every single post because there are around 100k posts.

有什么想法吗? 谢谢

推荐答案

首先,您要尝试处理症状,而不是问题.将来会为您带来更多问题.

Firstly you are attempting to treat the symptom, not the problem. This will cause more issues for you in the future.

但是,执行所需操作的最佳方法是在apache的.htaccess文件中使用重写规则.

However, the best way to do what you want is to use rewrite rules in apache's .htaccess file.

类似的事情应该起作用.根据需要进行修改.

Something like this should work. Modify as desired.

# add .html file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ /$1.html [L]

这篇关于重定向wordpress上的所有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆