You could add a condition to exclude URLs that can be mapped to actually existing files:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.* controller.php
The -f
keyword will test if the absolute path in %{REQUEST_FILENAME}
is a path to an existing regular file in the filesystem and !-f
is just the inverse.
But if you have a fixed list of directories you want to exclude, you could also do this:
RewriteCond $0 !^(assets|foo|bar)/
RewriteRule ^.* controller.php
This condition tests if the match of the whole RewriteRule
pattern (referenced with $0
) does not begin with neither assets/
nor foo/
nor bar/
. If you don’t want to process the match you could also use a negated expression directly in your RewriteRule
directive:
RewriteRule !^(assets|foo|bar)/ controller.php