Tuesday, August 17, 2010

CodeIgniter remove index.php from URL

Ok I needed to make a note of this cause there are hundreds of posts on this and this is my one to add to the mix on how I got it to work.
This was on my Ubuntu desktop where I'd setup CodeIgniter.

1)  Add .htaccess file to /var/www with the following content:

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

2) Check ModRewriter is enabled:


cat /etc/apache2/mods-enabled/rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so


3) Make sure AllowOverride is set to all

This file: /etc/apache2/sites-enabled/000-default
Should have section like:

       
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
       


4) Then restart apache if you made changes to apache config

And then you should be able to access site without the index.php in the URL.

NiCe :-)

No comments:

Followers