CodeIgniter CI框架URL重写:
把下面的代码保存到 .htaccess 中,这是为了去除默认的index.php所用
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|main|robots.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
// 之后找到 application/config/config.php 配置文件
$config['index_page'] = 'index.php'; //这行代码,修改成如下这样,默认的index.php就去掉了
$config['index_page'] = '';
接下来要做的就是重写URL了
找到 application/config/routes.php 路由配置文件,改写即可。