如何从帖子中删除帖子ID,然后重定向到新URL? [英] How to remove Post ID from posts and then redirect to new URL?
问题描述
我刚刚更改了我基于wordrpress的博客的永久链接结构。以前它具有这样的永久链接结构
I just changed the permalink structure of my wordrpress based blog. Previously it had the permalink structure like this
http://www.mysite.com/sample-post-example/2345/
网址末尾的数字是自动生成的由wordpress软件生成。实际上,这些数字是post_id。现在,我有了这个网址结构。
The numbers at the end of the url were automatically generated by wordpress software. In fact these numbers are post_id. Now I have this url structure.
http://www.mysite.com/sample-post-example/
现在的问题是,每个帖子都可以在两个url结构下使用。
Now the problem is that the individual posts are available under both url structures.
在删除旧URL末尾存在的Post_ID之后,是否仍然可以将旧URL重定向(301)到新URL?
Is there anyway to redirect (301) old URLs to new url after removing the Post_ID present at the end of the old URL??
推荐答案
检查此项目:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule (.+)/\d{4,5}/?$ $1/ [R=301,L]
这篇关于如何从帖子中删除帖子ID,然后重定向到新URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!