RewriteEngine on
RewriteBase /
#
# Internally rewrite all non-blank URL-path requests which do not resolve to physically-
# existing files to handler.php unless they have already been rewritten to handler.php
RewriteRule $1 !^handler\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ handler.php [L]
Note that handler.php now becomes responsible for generating all directories, images, multimedia files, css files, and external Javascripts which do not exist in physical files. It is also responsible for generating correct 404 and 410-Gone responses if it cannot generate them.
If your handler script cannot generate images, css files, Javasscripts, etc., then you should also exclude these filetypes from being rewritten to that script, using an additional RewriteCond such as:
RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
As an added bonus, the more of these filetypes you exclude, the faster your server will run, because it will not have to go read the disk to see if any of these filetypes exist or not... That is a very slow and resource-intensive function, so the less often you do it, the better. Plus your hard drive will last longer... :)
Consider also excluding "well-known" files such as robots.txt sitemap.xml, labels.rdf, and /w3c/p3p.xml
Jim