Remove index.php in CodeIgniter

梦想与她 提交于 2019-12-02 12:38:26

问题


I'm trying to remove the 'index.php' from CI Urls.

I've tried many solutions, none of them worked. I've already set these variables in 'config.php':

$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";

And my current .htaccess is:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^plugb.com$ [NC]
RewriteRule ^(.*)$ http://www.plugb.com/$1 [R=301,L]

RewriteCond $1 !^(index\.php|files|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

The www prefix part works fine. But the 'index.php' part doesn't. If you want to check the webpage, here is it: http://www.plugb.com/index.php/home


回答1:


There's instructions on how to do this in the URLs Section of the CodeIgniter User Guide under the section "Removing the index.php file".




回答2:


Take your application folder out of the system folder and use this code:

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

It should work.



来源:https://stackoverflow.com/questions/2760513/remove-index-php-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!