【问题标题】:codeigniter url handling to remove index.php and method namecodeigniter url 处理以删除 index.php 和方法名称
【发布时间】:2015-03-20 05:51:32
【问题描述】:

嗨,我第一次使用 codeigniter,我必须管理我的 URL 以在没有 index.php/controller 的情况下查看 URL,所以我如何编写 ht 访问权限以及我将其保存在哪里我的文件夹结构以及我必须进行的任何其他更改在我的自动加载或配置文件中执行....

my URL is like below...

project_name/index.php/controller_name/method_name/param 1/param 2

那么对于这个 URL,我该如何编写 ht 访问规则?请需要帮助......

【问题讨论】:

标签: php .htaccess codeigniter url-rewriting url-routing


【解决方案1】:

打开 config.php 并进行以下替换

$config['index_page'] = "index.php"

$config['index_page'] = ""

只需替换

$config['uri_protocol'] ="AUTO"

$config['uri_protocol'] = "REQUEST_URI"

并在 HTACCESS 文件中放入以下代码

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

【讨论】:

    【解决方案2】:

    将此代码放入您的 .htaccess 文件中。

    RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule .* index.php/$0 [PT,L] 
    

    【讨论】:

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