CI框架uri去掉index.php

时间:2023-03-09 02:09:07
CI框架uri去掉index.php

CI框架的入口是index.php,所以url实际上要多出一个index.php,非常不美观。我使用的是apache服务器,要开启mod_rewrite服务才可以。

    sudo a2enmod rewrite
sudo service apache2 restart

复制下面的信息:

   RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

保存为.htaccess文件, 放在index.php同级目录下面。

修改application/config.php中的参数配置:设置$config['index_page'] = ""。重新运行程序成功。