欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解析如何去掉CodeIgniter URL中的index.php

 更新時(shí)間:2013年06月25日 17:44:22   作者:  
本篇文章是對(duì)如何去掉CodeIgniter URL中index.php的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
CI默認(rèn)的rewrite url中是類似這樣的,例如你的CI根目錄是在/CodeIgniter/下,你的下面的二級(jí)url就類似這樣http://localhost/CodeIgniter/index.php/welcome。不太好看,怎么把其中的index.php取掉呢?

1. 打開(kāi)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文件夾,這些需要過(guò)濾除去,第二行需要改寫為: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

相關(guān)文章

最新評(píng)論