【问题标题】:Problems with redirect, permalinks wordpress重定向问题,永久链接 wordpress
【发布时间】:2016-09-29 13:20:22
【问题描述】:

我有一个 wordpress 网站,网址是 www.mysite.com/name-of-the-post

但客户端更改为 www.mysite.com/blog/name-of-the-post

现在我遇到了点击旧链接的用户的问题,他们无法访问内容。

我该如何解决这个问题?我在 htaccess 上阅读了一些关于正则表达式的内容,当用户尝试访问旧链接时,如何添加“/blog”?

谢谢大家

【问题讨论】:

    标签: php wordpress .htaccess url redirect


    【解决方案1】:

    我将把这段代码放在哪里?我的 htaccess 是这样的:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
    
    # Force HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    

    【讨论】:

    • 好吧,我不精通 wordpress 相关问题,但请在 index.php 规则结束后在您的 wordpress 规则中尝试,仅应用这么多规则RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #internally rewriting requests to original working url RewriteRule ^([\w-]+)$ blog/$1 [L]
    猜你喜欢
    • 1970-01-01
    • 2013-08-14
    • 2016-02-11
    • 2017-12-20
    • 2015-12-04
    • 1970-01-01
    • 1970-01-01
    • 2019-07-08
    相关资源
    最近更新 更多