【问题标题】:Redirect Wordpress Permalink in htaccess在 htaccess 中重定向 Wordpress 永久链接
【发布时间】:2013-04-25 18:00:20
【问题描述】:

我想将我网站的永久链接结构从 /%postname%/ 更改为 /%category%/%post_id%/%postname%/ ,并将旧反向链接重定向到新结构(目前得到 404)。我尝试了几个不同的重定向插件(重定向,301 简单插件),但我无法让它们工作。

有人可以告诉我将规则放入 htaccess 文件吗?

谢谢!

【问题讨论】:

    标签: wordpress .htaccess redirect permalinks


    【解决方案1】:

    如果您知道给定帖子名的明确类别和 post_id,那么您可以单独创建重定向:

    Redirect 301 /example-post-name-to-redirect/ /example-category/1234/example-post-name-to-redirect/ 
    

    或使用 mod_rewrite(注意,这些规则必须在你的 wordpress 规则之前:

    RewriteRule ^example-post-name-to-redirect/$ /example-category/1234/example-post-name-to-redirect/ [L,R=301]
    

    但更好的解决方案是使用 wordpress 为您执行此操作,您是否尝试过:UrbanGiraffe Redirection pluginScott Yang's Permalink Redirect WordPress PluginYoast's Permalink Redirect WordPress Plugin

    【讨论】:

    • 嗨,我的网站有 1000 条帖子,因此为每个帖子手动执行此操作绝对不理想。我已经尝试过 UrbanGiraffe 一个(运气不好),但我也会尝试其他两个。
    • 你好,Yoast 的插件很有效(另一个没有)。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-08-14
    • 2016-02-11
    • 2017-12-20
    • 2015-05-04
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多