|
1. 打開apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so,把該行前的#去掉。
搜索 AllowOverride None(配置文件中有多處),看注釋信息,將相關(guān).htaccess的該行信息改為AllowOverride All。
2. 在CI的根目錄下,即在index.php,system的同級(jí)目錄下,建立.htaccess,直接建立該文件名的不會(huì)成功,可以先建立記事本文件,另存為該名的文件即可。內(nèi)容如下(CI手冊(cè)上也有介紹):
復(fù)制代碼 代碼如下:
RewriteEngine on
RewriteCond $1 !^(index/.php|images|robots/.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目錄下,例如我的是:http://www.nowamagic.NET/CodeIgniter/,第三行需要改寫為RewriteRule ^(.*)$ /CodeIgniter/index.php/$1 [L]。
另外,我的index.php的同級(jí)目錄下還有js文件夾和css文件夾,這些需要過濾除去,第二行需要改寫為:RewriteCond $1 !^(index/.php|images|js|css|robots/.txt)
3.將CI中配置文件(system/application/config/config.php)中$config['index_page'] = "index.php";將$config['index_page'] = ""; 。
復(fù)制代碼 代碼如下:
/*
|--------------------------------------------------------------------------
| 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'] = '';
重啟apache
php技術(shù):解析如何去掉CodeIgniter URL中的index.php,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。