.htaccess URL 重写 WordPress 旧固定链接
我有一个博客,其中有基于旧日期的永久链接。 EG:Blog.com/2011/10/post-name
我的新永久链接现在是基于类别和帖子名称的,但前面也有 /blog/。 EG:Blog.com/blog/category-name/post-name
我需要在 HT Access 文件中做什么来克服问题?到目前为止我有类似的东西但目前没有工作..
#RewriteRule ^[0-9]{4}/[0-9]{2}/.*$ /blog/$1 [R=permanent,L]
I have a blog which had old date based permalinks. EG: Blog.com/2011/10/post-name
My new permalinks now are category and post name based, but also are preceded by /blog/. EG: Blog.com/blog/category-name/post-name
What do i need to do in my HT Access file to overcome thins? I have something like this so far but currently not working..
#RewriteRule ^[0-9]{4}/[0-9]{2}/.*$ /blog/$1 [R=permanent,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
/blog/2011/10/post-name
也已重定向您/blog/category/post-name
(确保它是 301),那么您所需要的一切要做的就是发送/2011/10/post-name
到/blog/2011/10/post-name
您可以通过将以下规则放入根目录的 .htaccess 文件中来完成此操作您网站的。
If
/blog/2011/10/post-name
already redirects you too/blog/category/post-name
(make sure it is a 301), then all you need to do is to send/2011/10/post-name
to/blog/2011/10/post-name
You can do this by putting the rules below in the .htaccess file in the root of your site.
这看起来与将网站从 /blog/ 移动到根目录有关;是这样吗?
如果是这样,您应该在数据库中查找/替换 URL,以便不必使用 .htaccess 规则。
在 phpmyadmin 中运行的此查询将更新帖子 guid 以摆脱 /blog/ 路径:
您可能还需要更改帖子内容中的 URL:
This looks like it has to do with moving the site from /blog/ to root; is that the case?
If so, you should find/replace the URLs in the database as to not have to use a .htaccess rule.
This query run in phpmyadmin will update post guid's to get rid of the /blog/ path:
You may also need to change URLs in post content: