【问题标题】:Htaccess redirect from index.php to non-indexHtaccess 从 index.php 重定向到非索引
【发布时间】:2018-05-06 19:47:33
【问题描述】:

我想通过以下方式重定向到我的 htaccess:

http://example.com/index.php -> http://example.com
http://example.com/index.php/controller -> http://example.com/controller
http://example.com/index.php/controller/any-method -> http://example.com/controller/any-method

简而言之,我想检测 URL 是否包含 index.php 并将其重定向到没有它的 url,但要在 index.php 之后保留其他段

提前谢谢你。

【问题讨论】:

    标签: regex apache .htaccess redirect mod-rewrite


    【解决方案1】:

    这对我有用:

    RewriteCond %{REQUEST_URI} ^/index.php/
    RewriteRule ^index.php/(.*) /$1 [R,L]
    

    【讨论】:

    • 我正在寻找类似的东西。该解决方案通过文件根目录而不是我的网络根目录重定向到路径。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-21
    • 2014-08-31
    • 2021-04-19
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多