原文地址:http://www.nowamagic.net/php/php_RemoveIndexInCi.php
CI默認的rewrite url中是類似這樣的,
例如你的CI根目錄是在/CodeIgniter/下,
你的下面的二級url就類似這樣
http://localhost/CodeIgniter/index.php/welcome。
不太好看,怎么把其中的index.php取掉呢?
1. 打開apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so,
把該行前的#去掉。
搜索 AllowOverride None(配置文件中有多處),
看注釋信息,將相關.htaccess的該行信息改為AllowOverride All。
2. 在CI的根目錄下,即在index.php,system的同級目錄下,
建立.htaccess,內容如下(CI手冊上也有介紹):
RewriteEngine on RewriteCond $1 !^(index.php|images|robots.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
/*|--------------------------------------------------------------------------| Index File|--------------------------------------------------------------------------|| Typically this will be your index.php file, unless you've renamed it to| something else. If you are using mod_rewrite to remove the page set this| variable so that it is blank.|*/$config['index_page'] = '';
ok,完成。還要記得重啟apache。