【问题标题】:How do i rewrite this url address我如何重写这个url地址
【发布时间】:2011-10-15 12:28:10
【问题描述】:

我有一个类似于 http://domain.com/index.php/view/test 的 URL。我如何重写它,使其中没有index.php/view。我只想让它看起来像http://domain.com/test。我希望用户能够直接在浏览器中输入该短网址

我在.htaccess 中尝试了以下操作,但没有成功

RewriteEngine  on
RewriteRule ^/$ index.php/view/

我正在运行 php 5.2.17

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting


    【解决方案1】:
    RewriteBase /
    RewriteCond %{REQUEST_URI}  !^/index.php/view/(.*)$
    RewriteRule ^(.*)$ index.php/view/$1 [L]
    

    【讨论】:

      【解决方案2】:
      RewriteEngine On
      RewriteBase /
      RewriteRule ^(.*)$ index.php/view/$1 [L]
      

      如果我理解正确的话会这样做。

      【讨论】:

      • 这是一个内部服务器错误
      • 哇,它真的不应该,我添加了[L] 标志我不认为这可以解决问题?
      • 添加RewriteBase 语句有帮助吗?
      • 我认为问题一定出在其他地方,我只是快速设置并尝试过,重写按预期发生:/test 内部转发到index.php/view/test
      • 嗯,你认为它可能是什么。我在哪里看。
      猜你喜欢
      • 1970-01-01
      • 2013-02-27
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 2011-05-22
      • 1970-01-01
      • 2011-11-19
      相关资源
      最近更新 更多