[记录]CodeIgniter去掉URL中index.php

去掉conf/httpd.conf里的LoadModule rewrite_module modules/mod_rewrite.so的注释。

设置Codeigniter的config.php文件,该文件默认在/system/application/config目录下。 将其中的$config[‘index_page’] = “index.php"一项改为$config[‘index_page’] = “”;

假设你在测试环境种你放置在codeigniter目录下,新建.htaccess文件,.htaccess文件内容如下:

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

或者配置为: RewriteEngine on RewriteBase /codeigniter/ RewriteCond $1 !^(index\.php|images|robots\.txt|files) RewriteRule ^(.*)$ index.php/$1 [L]