【问题标题】:mod_rewrite redirection issuemod_rewrite 重定向问题
【发布时间】:2011-05-16 12:44:49
【问题描述】:

我已经查看了相关问题,但没有运气。

我正在尝试重写如下内容:http://www.example.com/v2/index.php/en/company/careers/training-and-implementation-specialist/

对此:http://www.example.com/en/company/careers/training-and-implementation-specialist/

为了让事情更加混乱,上面 URL 中的“index.php”是一个文件,而不是一个目录。我正在尝试制定一个规则,将 www.example.com/v2/index.php/(anything) 变成 www.example.com/(anything)

我觉得这应该很容易,我尝试了这个:RewriteRule ^v2/index.php/(.*) /$1 [L]

但没有运气——我在 /v2/index.php 中尝试的任何东西都会得到 404。

有什么建议吗?

【问题讨论】:

    标签: apache mod-rewrite redirect


    【解决方案1】:

    如果我理解你想要做什么,我相信你有它倒退。试试这个:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ v2/index.php/$1 [L]
    

    【讨论】:

      【解决方案2】:

      问题在于.RewriteRule ^v2/index.php/(.*) /$1 [L] 中的索引和php 之间

      改写试试-RewriteRule ^v2/index\.php/(.*)$ /$1 [L]

      如果要重定向,请将[L] 更改为[R,L]

      【讨论】:

        猜你喜欢
        • 2014-11-16
        • 1970-01-01
        • 1970-01-01
        • 2011-08-14
        • 2015-03-11
        • 2016-05-23
        • 2014-09-05
        • 1970-01-01
        • 2012-05-31
        相关资源
        最近更新 更多