[英]Rewrite IIS Url's Except App Root
我讨厌正则表达式,但它讨厌我,这是问题所在:
我正在处理臭名昭著的Angular路由和旧版浏览器(IE9 +),我解决了所有问题,但有一个问题,那就是在IE中,应用程序的根URL需要正斜杠(并且只有根)。 同时,我需要从其他非根请求中删除所有正斜杠,如以下借用代码片段所示:
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
这完美地工作了,我只是不知道该如何获取请求: http://localhost/jumpstart
改写为: http://localhost/jumpstart/
并带有反斜杠,同时为非应用程序根请求保留其他规则。
我以为*\\/jumpstart(?!\\/)
匹配就足够了,但是无法正常工作。
任何帮助,将不胜感激。
谢谢!
您应该能够使用诸如:
<rule name="Add trailing slash to jumpstart" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="(.*?)jumpstart$" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}/" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.