Fallback Resource

If you’re like me, then you are useless at remembering a couple of things which tend to start a project. I recently found the “FallbackResource” command in Apache.

This single command replaces the mod_rewrite rules:

	RewriteEngine On
	RewriteBase /
	RewriteRule ^index\.php$ - [L]
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]

with the single command

FallbackResource /index.php

I can remember that one! It basically does the same thing – If the file does not exist (any file, such as css/images/PHP scripts) then it will route it to index.php.

Tagged with: , ,
2 comments on “Fallback Resource
  1. Alan Wynn says:

    For the FallbackResource you have forgotten to include the location of index.php

    For it to work correctly, you need to set the uri location (from the domain root) to the fallback resource. For example if the index.php is in the root of the domain, then the code should be as follows:
    FallbackResource /index.php

    ref: http://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource

  2. Alan Farquharson says:

    Looks like you are correct 🙂 Edited, thanks!

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.