My ultimate .htaccess file for CodeIgniter 2.0

#Initialize mod_rewrite
RewriteEngine On
RewriteBase /

#Force "www" subdomain
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Re-route forbidden urls
RewriteCond %{REQUEST_URI} ^(system|application).* [OR]
RewriteRule ^(.*)$ index.php?/$1 [L]

#Re-route urls if file/directory does not exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

2 thoughts on “My ultimate .htaccess file for CodeIgniter 2.0

  1. dav_twix

    thanks to share it !

    I looked for the way to supress ‘index.php’ AND force WWW in htaccess file

    You save my time !


Leave a Reply

Your email address will not be published. Required fields are marked *