Removing index.php in codeigniter

Hey Folks, most of the new CodeIgniter developers face a problem to remove index.php from the URL. It’s pretty simple.

Just write the following code in notepad and save as .htaccess. Put this file in the root folder where application, system folders are.

.htaccess code:

RewriteEngine on

#remove access to system folder
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#check if user is accessing a file or folder that already exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

or in MAMP

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

And of course, make sure mod_rewrite is enabled in your server.


You may also like...

Leave a Reply

%d bloggers like this: