我在目录/ 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路由逻辑,第一个段是控制器名称,第二个段是动作
可以解决????只是不想在主页上太长的网址
1 回答
documentation实际上声明控制器可以't be named '索引' because it' s保留字 .
如果你的目标是获得漂亮的URL,你应该保留原来的默认控制器,并将$ config [“index_page”]变量留空 .
然后创建此.htaccess文件:
这会让CI和你成为幸福的一对......