【问题标题】:Changing URL schemes in wordpress without breaking old URLs在不破坏旧 URL 的情况下更改 wordpress 中的 URL 方案
【发布时间】:2010-10-15 19:38:19
【问题描述】:

我创建了一个博客,在几篇文章之后,我决定不喜欢 /2009/03/26/foo-bar 的 URL 方案(我改为仅 /foo-bar)。但是对于我更改此内容之前发布的几篇帖子,我想添加重写规则,以免旧 URL 损坏。

我已经尝试了 .htaccess 文件中我能想到的以下所有变体,但无济于事:(请注意,除了“first-post”和“second-post”行之外的所有内容都是 wordpress 样板)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule /2009/03/25/first-post /first-post
RewriteRule /2009/03/26/second-post /second-post

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

有什么想法吗?

【问题讨论】:

    标签: wordpress url url-rewriting blogs friendly-url


    【解决方案1】:

    试试

    RewriteRule ^\d*/\d*/\d*/(.*) /$1
    

    【讨论】:

    • 不起作用!如果它确实有效,我喜欢解决方案的普遍性。 :)
    【解决方案2】:

    我刚刚尝试过的一个可行的解决方案是实际创建目录和子目录 2009/03/25/ 等,然后添加一个包含以下内容的 index.php 文件:

    <?php
    header('Location: http://example.com/first-post');
    ?>
    

    【讨论】:

    • 事实证明这个解决方案真的不可行,因为它搞砸了 feedburner 对读者统计数据的跟踪。
    【解决方案3】:

    试试 Dean Lee 的Permalink migration plugin

    【讨论】:

      猜你喜欢
      • 2019-02-28
      • 1970-01-01
      • 2014-08-13
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-21
      • 2017-08-21
      相关资源
      最近更新 更多