Excluding directory with ISAPI-Rewrite

I'm trying to exclude a directory with ISAPI-Rewrite (note: this is the windows / iis mod-rewrite port).

The directory I want to exclude is "api" when it is in the root of the site.

Here's my rule:

RewriteRule ^ (/api/)(.+)$ $ 1 $ 2 [NC, L]

The request would look something like / api / v 2 / users? Logins = scottw

Unfortunately the querstring value is always excluded and the url is rewritten as / api / v 2 / users.

I attack on the assumption that (. +) Will take over everything else.

Any suggestions? Or a better way to exclude a directory?

thanks

Update . I also simplified the rule, but that didn't change anything:

RewriteRule ^ (/api/.+)$ $ 1

+1


a source to share


2 answers


It turns out there are two things here:

  • The regex should be ^ (api /), not ^ (/ api). The first "/" is excluded.
  • The regular expression parser tool that comes with ISAPI_Rewrite does not seem to handle repetitions correctly.


The rule that finally works is as follows:

RewriteRule ^(api/.+) $1 [NC,L]

      

+2


a source


I've seen the "+" work strange sometimes, you can try going to "..". I'm not saying it will work, but it might be worth trying.



0


a source







All Articles