Hi friends, in this post I am going to explain how to removing index.php from URLs in CodeIgniter framework. In earlier we have learned few topics regarding CodeIgniter i.e. Pagination, Upload images and Database connection. Now we will learn how to remove index.php from URLs.
.htaccess file in root directory
1 2 3 4 5 | RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] |
In the application folder
1 2 3 4 5 | <IfModule mod_rewrite.c> RewriteEngine On RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] </IfModule> |
In application/config/config.php
search for
1 | $config['index_page']='index.php'; |
and replace it with
1 | $config['index_page'] = ''; |
Now we will get URLs without index.php
I am writing this code based on CodeIgniter 2.2.1
2 Comments
Civil Machines · April 11, 2015 at 7:57 am
great…
karthik · March 18, 2016 at 7:39 am
Thanks .