Friday, June 17, 2011

Codeigniter: Remove index.php on url

After many months stopping to learn codeigniter, now I am back to learn it again. So my first issue I have got after successfully installing it is, having "index.php" on the url, I read on user guide about how to remove it, but it did not fix the issue, so I looked it up in google and found the way to remove it.


So this is how to remove the default index.php from the url:
1. edit the file application/config/config.pho line 29:
-  $config['index_page'] = 'index.php';
+ $config['index_page'] = '';
2. create new .htaccess file on the root folder, then add below snippet:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
That is it.. =)

No comments:

Post a Comment