【问题标题】:Remove "index.php" from URL从 URL 中删除“index.php”
【发布时间】:2014-01-21 10:59:45
【问题描述】:

我有这个链接

localhost/MySite/queues/index.php

index.php 已使用 .htaccess 删除,我得到的 URL 如下。

本地主机/MySite/队列

现在的问题是,当我像这样在索引函数中使用段时:

queues.php --> 控制器

function index($sgmnt = 'test'){
   $this->load->view('queues_view/'.$sgmnt);
}

我想要这个链接

本地主机/MySite/队列/测试

不是

localhost/MySite/queues/index.php/test

或者我仍然可以输入

localhost/MySite/queues/index.php/test

但网址必须只显示

本地主机/MySite/队列/测试

【问题讨论】:

  • 我建议查看stackoverflow.com/questions/21255164/…,这是刚才提出的一个问题,但它提供了一个.htaccess 文件的示例,如果您使用的是apache,则需要该文件
  • No @micb 它不是典型的通过 .htaccess 删除 index.php。在索引函数中使用段是不同的。它不是另一个函数,我调用它仍然是索引,但上面有段。

标签: php codeigniter


【解决方案1】:

以上配置设置

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

【讨论】:

    【解决方案2】:

    为此,您可以利用 htaccess.open htaccess 并将这些行添加到其中。我希望它会起作用(http://localhost/MySite/queues/test)。

    RewriteEngine On
    RewriteRule ^MySite/queues/test$ /MySite/queues/index.php [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-14
      • 2014-10-28
      • 2012-06-15
      • 2011-05-20
      • 2012-09-21
      • 2011-10-12
      相关资源
      最近更新 更多