【问题标题】:Remove 'index.php' from url without removing parameters in .htaccess从 url 中删除“index.php”而不删除 .htaccess 中的参数
【发布时间】:2013-01-01 19:53:18
【问题描述】:

我有一个 url 重定向的条件,例如,

www.domain.com/something/anotherthing/index.php

我需要上面的网址重定向到

www.domain.com/something/anotherthing/

如果我去

www.domain.com/index.php/something/anotherthing

我想重定向到

www.domain.com/something/anotherthing

我对此有一个重定向 htaccess 规则

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php$1 [NC]

重写规则 ^ /%1$1 [R=301,L]

但这适用于第一个条件,但在后面它将我重定向到根页面。任何人都可以在此重定向中提供帮助。

提前致谢。

【问题讨论】:

    标签: .htaccess redirect indexing permanent


    【解决方案1】:

    试试这样的:

    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC]
    RewriteRule ^ %1/%2 [R=301,L]
    

    这应该处理/index.php的任何位置。

    【讨论】:

      猜你喜欢
      • 2011-05-20
      • 2017-03-15
      • 1970-01-01
      • 2020-09-02
      • 2015-07-21
      • 2013-05-15
      • 2021-10-02
      • 2015-01-20
      相关资源
      最近更新 更多