【问题标题】:Ignored mod_rewrite instructions in .htaccess (WordPress)忽略 .htaccess (WordPress) 中的 mod_rewrite 指令
【发布时间】:2012-09-11 12:15:24
【问题描述】:

我们更改了 WordPress 博客的永久链接结构(我知道这是个坏主意)。我试图在 WordPress 安装的基本文件夹的 .htaccess 中使用 mod_rewrite 指令避免来自外部链接的 404:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^\d\d\d\d\-\d\d\-\d\d_(.+)$ $1 [L]
# other rewrites
</IfModule>

我尝试了一些变体,甚至测试了一个页面的完整 URL,但该行一直被忽略。但是 mod_rewrite 正在运行 - 其他一些重写,例如

RewriteRule ^seiten/abo\.php[5]?$   subscribe.php5 [R=301,L]

完美运行。我被困住了。有人可以帮忙吗?

【问题讨论】:

    标签: regex wordpress .htaccess mod-rewrite


    【解决方案1】:

    尝试通过在方括号中添加 R=301 标志来强制执行 301 重定向:

    RewriteRule ^\d\d\d\d\-\d\d\-\d\d_(.+)$ $1 [L,R=301]
    

    这将使其他重写不会(在第一次重写迭代之后)修改 URI。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-04
      • 2021-04-11
      • 2014-05-12
      • 2014-01-06
      相关资源
      最近更新 更多