> Handlers

Handlers are things built into Apache to handle requests. Hence the clever name. mod_rewrite allows you to direct requests to handlers using the Flags/H and Flags/T Flags.

For example, if you want all files without a file extension to be handled by PHP, you could use:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. - [H=application/x-httpd-php]

Note that the H flag is only available in 2.1 or later, so, for earlier versions of Apache, you have to do:

RewriteRule !\. - [T=application/x-httpd-php]

Which does exactly the same thing (in this case) but is less correct.

Remember that REQUEST_FILENAME does not contain the full physical path in per-server context which is needed to check for existing directories. You might have to use one of the following variants instead:

# if you know, that the request wohld go into the DocumentRoot
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
# or somewhere else, prefix it manually
RewriteCond /var/www%{REQUEST_FILENAME} !-d
# if you can't say for sure, that the file is stored inside of a specific path, you must
# use an URL-based subrequest to determine the full physicall path.
# Use it with care, it decreases performance.
RewriteCond %{LA-U:REQUEST_FILENAME} !-d

Note: Substituting the request with an URL-path and using the H/T flag will only work in per-server context. If you use this flag in per-dir context you must use the minus (-) in the substitution like above. This stands for 'no substitution'. Otherwise the handler (H flag) or the MIME type (T flag) will be lost with the internal redirect.