Codeigniter Index Controller路由问题

use*_*344 4 routing codeigniter

我在目录/ system/application/controller /下有一个索引控制器名称Index.php

我已经设定了.htacesss的规则

RewriteEng on RewriteCond $ 1!^(include || index.php | images | robots.txt)RewriteRule ^(.*)$ /index.php/$1 [L]

然后我转$ route ['default_controller'] ="index";

和我配置$ config ['index_page'] ="";

我在我的控制器中有一个索引动作

当我访问http:// domain/index/index/en将有404

当我访问http:// domain/index/index/index/en时会没问题

我尝试在Libraries/Router.php中回显$ this-> uri-> segment

发现如果我使用index/index/en请求,它只返回index和en

如果我请求index/index/index/en它返回index,index和en,

作为ci路由逻辑,第一个段是控制器名称,第二个段是动作

可以解决???? 只是不想在主页上太长的网址

Rep*_*pox 10

文件实际上指出控制器不能命名为"索引",因为它是一个保留字.

如果你的目标是获得漂亮的URL,你应该保留原来的默认控制器,并将$ config ["index_page"]变量留空.

然后创建此.htaccess文件:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

这会让CI和你成为幸福的一对......