[英]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 http://example.com:9999/bundles/bundle.js
And IIS redirects me to http://example.com:9999/bundles/bundle.js/ IIS将我重定向到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. 但是我转到IIS管理器,转到IIS重写,选择此规则,进行测试,将URL放入,单击测试,它说这不匹配。
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 因此,它无法正常工作:您的规则
(^((?!\\/bundles\\/).)*[^\\/]$)
匹配 http://example.com:9999/bundles/bundle.js
The problem in your rule. 您的规则中的问题。 Correct rule is
(^((?!bundles\\/).)*[^\\/]$)
. 正确的规则是
(^((?!bundles\\/).)*[^\\/]$)
。 I removed slash before bundles
. 我在
bundles
之前删除了斜杠。 Because when request is coming into rule, it is comparing rule with path bundles/bundle.js
(without starting slash) 因为当请求进入规则时,它会将规则与路径
bundles/bundle.js
进行比较(不带斜杠)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.