Tuesday, March 16, 2010

Php - How to remove index.php from codeigniter url

This is the best way to get ride of index.php from your website's url which is build using codeigniter framework.


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



copy and paste the above code in  .htaccess file in your website root.Ensure that no extra  whitspaces are included before or after the codes.

In config.php you can replace

$config['index_page'] = "index.php"; 
with this
$config['index_page'] = "";

Happy coding...