CodeIgniter - How to hide index.php from the URL

2019-02-22 07:57发布

问题:

This is what my .htaccess looks like. The .htaccess is sitting in /www/scripts directory which is the parent of codeigniter's system directory and which also contains index.php. I have enabled mod_rewrite in my Apache 2.2.x. This is on Ubuntu 9.10 server.

I followed this link, but it does not work. Is there anything I need to do in apache2, any specific configuration so that this works?

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

回答1:

use this:

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


回答2:

Just toss the following code into your .htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Source: http://codeigniter.com/user_guide/general/urls.html



回答3:

Try these links, it may help your question:
http://ellislab.com/forums/viewthread/153950/
http://ellislab.com/forums/viewthread/153372/



回答4:

here is the solution simply drop in root.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 



回答5:

CodeIgniter User Guide on URLs