4

使用以下规则,我可以成功重写 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>

但是一旦我开始使用缩小的内容,请求的 URL 就会类似于:

/myapp/bundles/utilities?v=EH9YuZDBt_fj7iqRP2QA8lCkJ59wjV6woELIwvR7irk1

如何防止这种类型的 url 被重定向?

4

1 回答 1

6

You can create a ignore rule, match URLs to ignore

<rule name="Ignore" enabled="true" stopProcessing="true">
   <match url="^(images|css|bundles).*"/>
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
   <action type="None"/>
</rule>
于 2013-06-20T11:47:46.270 回答