简体   繁体   中英

IIS matches the rule but IIS rewrite module says the rule doesn't match

I'm having an issue with a rule being applied correctly on my site.

The rule is:

(^((?!\/bundles\/).)*[^\/]$)

The action is to append a slash to the end of this, using:

<action type="Redirect" url="{R:0}/" redirectType="Temporary" />

I try the following url:

http://example.com:9999/bundles/bundle.js

And IIS redirects me to http://example.com:9999/bundles/bundle.js/

But I go to IIS Manager, go to IIS Rewrite, select this rule, go to test, put the url in, click test, and it says that it's not a match.

If it's not a match, why is it still redirecting?

I created the same rule and it is redirecting. So, it is working as not expected: your rule (^((?!\\/bundles\\/).)*[^\\/]$) match to http://example.com:9999/bundles/bundle.js

The problem in your rule. Correct rule is (^((?!bundles\\/).)*[^\\/]$) . I removed slash before bundles . Because when request is coming into rule, it is comparing rule with path bundles/bundle.js (without starting slash)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM