【问题标题】:Reformat link structure to match Wordpress重新格式化链接结构以匹配 Wordpress
【发布时间】:2017-10-19 22:15:04
【问题描述】:

我将博客从 Weebly 迁移到 Wordpress,我们在 Facebook 中有链接到 Weebly 用于帖子的旧 URL 结构。这部分 /1/post/.html 在 Wordpress 中导致 404。

有没有办法使用 301 重定向来删除导致问题的 URL 部分。或者使用 Wordpress 中的 template redirect 钩子和正则表达式来解决这个问题?

Weebly
example.com/1/post/2016/09/some-post.html

WordPress
example.com/2016/09/some-post/

【问题讨论】:

    标签: php regex wordpress url-redirection http-status-code-301


    【解决方案1】:

    在您的 .htaccess 文件中尝试此代码:

    RewriteEngine On
    RewriteRule ^\d+/\w+/(\d+)/(\d+)/([\w\-]+).+$ /$1/$2/$3/ [L,R=301]
    

    我在这个网站上测试了它:http://htaccess.mwl.be,它似乎工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-26
      • 2019-05-28
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多