Routing requests to index.php with Apache

Posted by Andrew McCombe on Mon Mar 25, 2013

Routing requests to index.php with Apache

Here’s how to go about routing requests to index.php with Apache. I’m always having to search for this online so I thought I’d document it here. Many of the ‘modern’ PHP applications use index.php as a router, including WordPress, Drupal, Zend Framework, Silex etc.

Using Mod_Rewrite

If you are using Apache pre-2.5 then your only option is to use mod_rewrite to route requests to index.php:

RewriteRule ^index\.php$ - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L,QSA]

Using the FallbackResource Directive

From Apache 2.5 onwards you can use the new FallbackResource Directive:

FallbackResource /index.php

Documentation for this is available at