Skip to content

Mod Rewrite to index.php file, the easy way

Dec 27, 2011 1 min read #apache

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.

How many of you have written this before (or something very much like it):

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
apache

You might recognize something like this from the Zend Framework .htaccess file. Basically, the point is to say if something doesn’t exist, point it to the index.php file. Well, there is a simpler way to do this - I can’t believe I didn’t know this till now…

Apache Fallback Resource

All of that configuration now becomes this:

FallbackResource /index.php
apache