只需要在目录下新建立一个配置文件,命名为: .htaccess
在里面这样写:
复制内容到剪贴板TEXT 代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
就可以去掉 index.php 了。要注意 /index.php/$1 要根据你目录(Web 目录,比如 http://www.domain.com/index.php)的实际情况来定,比如网站根目录是 /ci/index.php 则要写成 /ci/index.php/$1
哦,对了,还要修改 config.php 这个文件中的下列内容:
复制内容到剪贴板PHP 代码:
/*
|--------------------------------------------------------------------------
| 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'] = "index.php";
把其中的 "index.php" 改成 "" 就可以了。