I\'m trying to create a rule used in a .htaccess file to match anything but a particular string, in this case: index
.
I thought that it sho
(Please read the comments. I doubt it and I've never encountered problems, while it gives one much cleaner .htaccess
files, but: using RewriteCond
might be preferred over using RewriteRule
with a dash, due to how rulesets are processed?)
Just use RewriteRule as follows, to not rewrite (the dash), and stop subsequent rewriting (the [L]
) for anything that starts with index/
:
# Do not rewrite anything that starts with index/ RewriteRule ^index/ - [L]
After this, do any rewriting you like.
Or maybe even limit some more first:
# Do not rewrite files, directories or symbolic links RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule . - [L]