If Only I Knew That!

Webby things that could save you time

An improved .htaccess file to remove index.php in CI

with one comment

A quick update of the .htaccess to remove the index.php, while still protecting the application folder.

The previous method I used meant having to add every real file or directory to the .htaccess to allow them to be accessed. The updated way checks if the requested file/directory exists and if need rewrites to the index.php.

If you need to protect more directories separate them with | i.e. application|modules

RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Written by daveganley

August 7th, 2009 at 8:43 am

Posted in Codeigniter

Tagged with , ,

One Response to 'An improved .htaccess file to remove index.php in CI'

Subscribe to comments with RSS or TrackBack to 'An improved .htaccess file to remove index.php in CI'.

  1. Golden. I have been looking all over how to do this and you have it all wrapped up! Good job.

    TheServant

    18 Sep 09 at 6:11 pm

Leave a Reply

Powered by CDN Rewrites