Mod Rewrite to index.php file, the easy way

Dec 27, 2011 apache
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with 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]

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
Go to All Posts