去掉CodeIgniter URL中的index.php

1.打开apache配置文件httpd.conf,将LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。

2.在apache配置文件中搜索 AllowOverride None,将相关.htaccess的该行信息改为AllowOverride All。

3.在CI的index文件所在目录下创建.htaccess文件,内容如下:   

RewriteEngine on 
RewriteCond $1 !^(index\.php|assets|robots\.txt) 
RewriteRule ^(.*)$ /项目名/index.php/$1 [L]

4.将CI中配置文件(application/config/config.php)中$config['index_page'] = "index.php",改为$config['index_page'] = ""。

5.重启apache。

 

备注:assets文件夹是静态资源不用考虑index.php的

posted @ 2016-06-19 09:05  清风叶  阅读(181)  评论(0编辑  收藏  举报