【问题标题】:Redirecting Wordpress permalink重定向 Wordpress 永久链接
【发布时间】:2016-02-11 23:12:10
【问题描述】:

如何从

重定向 Wordpress 永久链接
example.com/%year%/%monthnum%/%postname%.html

example.com/%postname%

我已经尝试通过一个插件来实现它,也尝试将以下代码添加到.htaccess 文件中,但它返回 404 not found 错误。

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://www.example.com/$3

【问题讨论】:

    标签: wordpress permalinks


    【解决方案1】:

    在您的 .htaccess 文件中试试这个:

    RewriteRule ^[0-9]{4}/[0-9]{2}/(.*)\.html$ /$1 [R=301,L]
    

    确保它高于默认的 WordPress 重写规则。

    例如

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteRule ^[0-9]{4}/[0-9]{2}/(.*)\.html$ /$1 [R=301,L]
    
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    

    【讨论】:

    • 很高兴它成功了。如果是正确答案,请点击我的答案左侧的勾号图标接受。
    猜你喜欢
    • 2013-08-14
    • 2017-12-20
    • 2015-12-04
    • 1970-01-01
    • 2019-07-08
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    相关资源
    最近更新 更多