# these prevent rewriting if the URI doesn't point to a resource
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# this prevents scripts from being rewritten
RewriteCond %{REQUEST_URI} !^.*/(css|scripts)

ErrorDocument 404 /404.php