使用以下规则,我可以成功重写URL以重定向到app/index.cshtml.不应该重定向像图像,CSS和javascripts这样的Som资源,所以我使用了条件:
<rule name="AngularJS">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" negate="true" pattern="\.png$" />
<add input="{URL}" negate="true" pattern="\.css$" />>
<add input="{URL}" negate="true" pattern="\.js$" />
</conditions>
<action type="Rewrite" url="app/index.cshtml" />
</rule>
Run Code Online (Sandbox Code Playgroud)
但是一旦我开始使用缩小的内容,请求的URL就会变得类似于:
/ MyApp的/捆绑/事业吗?V = EH9YuZDBt_fj7iqRP2QA8lCkJ59wjV6woELIwvR7irk1
如何防止重定向该类型的URL?
您可以创建忽略规则,匹配要忽略的URL
<rule name="Ignore" enabled="true" stopProcessing="true">
<match url="^(images|css|bundles).*"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
<action type="None"/>
</rule>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2524 次 |
| 最近记录: |