通过 .htaccess 将旧 WordPress URL 重写为新站点的 URL 结构
大家好,我已将网站从 WordPress 迁移到新的 CMS,并且我想通过重定向保留旧 URL。
WordPress 永久链接结构如下所示:
/2011/04/01/name-of-post
我保留了帖子段,所以我需要做的就是摆脱基于日期的路径并重定向到我的新目录结构:
/articles/view/name-of-post
到目前为止,我的尝试看起来像这样(在我的 .htaccess 文件中):
RewriteCond %{THE_REQUEST} /[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+) [NC]
RewriteRule ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /articles/view/$1 [L]
还没有运气。我也在那里尝试了 %{PATH_INFO}
,没有骰子。
如果来自那些更精通 Apache 重写规则的人提供帮助,我们将不胜感激。
Hey folks, I've migrated a site from WordPress to a new CMS, and I want to preserve the old URLs via a redirect.
The WordPress permalink structure was like so:
/2011/04/01/name-of-post
I've preserved the post slugs, so all I need to do is get rid of the date-based paths and redirect to my new directory structure:
/articles/view/name-of-post
My attempts thus far have looked like this (in my .htaccess file):
RewriteCond %{THE_REQUEST} /[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+) [NC]
RewriteRule ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /articles/view/$1 [L]
No luck yet. I tried %{PATH_INFO}
in there as well, no dice.
Any help from those more versed in Apache rewrite rules than would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的事情应该做。
Something like this should do.
它可以通过一个简单的 RewriteRule 来处理,如下所示:
It can be handled in one simple RewriteRule like this: