How to set apache to skip a directory before a catch-all RewriteRule

Most of PHP applications use internal PHP routing (any MVC framework like ZF, CakePHP… , including wordpress) use a catch-all rewrite rule.

In case a directory needs to be ignored from that (to avoid broken urls falling back to that catch-all route), use a RewriteCond


#.htaccess. Redirect all the URLs to index.php, except the ones  starting with /admin

RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ index.php [NC,L]