【问题标题】:Mode_rewrite adding index.php to end of urlMode_rewrite 将 index.php 添加到 url 的末尾
【发布时间】:2013-08-07 03:31:10
【问题描述】:

我想为我对这门语言的了解不够深而道歉,但我遇到了这样的问题。 我通过 mode_rewrite 进行了重定向,现在 url 是“localhost/url/url2/” apache,它重定向到 “localhost/url/url2/index.php”如何从url中删除“index.php?”

【问题讨论】:

  • 在您的问题中发布您的 .htaccess。

标签: php apache unix redirect url-rewriting


【解决方案1】:

你可以使用这条规则:

RewriteRule ^url/url2/$ /url/url2/index.php [L]

浏览器不会在 URL 输入中显示 index.php。

【讨论】:

    【解决方案2】:

    如果你只想删除 index.php 则将这样的代码放在 htaccess 中,

    RewriteRule ^/$ http://localhost/url/url2/index.php
    

    将此 htaccess 文件放在 index.php 所在的位置

    【讨论】:

      猜你喜欢
      • 2012-03-11
      • 2011-01-05
      • 2013-04-14
      • 2021-10-21
      • 1970-01-01
      • 2021-11-17
      • 2012-08-03
      • 1970-01-01
      • 2017-06-15
      相关资源
      最近更新 更多