In my previous post i mentioned connect-modrewrite middleware, which can be used to enable live reload of angular app. When I was trying to implement regexp for modrewrite, I found it was really challenging to have regular expression with exclusions and “and” conditions.
The solution is to use inverted conditions and then negate the whole expression.
Here is the example: Say you need to configure rewrite rule for all request starting with
and not containing
// starting with /fr and not containing .js
So the way to do it is to create inverted regular expression
// not starting with /fr or containing .js "^/(?!fr)|\\.js$"
And then negate it in the modrewrite rule:
modRewrite([ '!^/(?!fr)\\.js$ /fr/index.html [L]' ])
blog comments powered by Disqus