IIS 网址重写 : how to ignore minified javascript and css

标签 iis url-rewriting

使用以下规则,我可以成功重写 url 以重定向到 app/index.cshtml。不应重定向图像、css 和 javascripts 等一些资源,因此我使用了条件:

 <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 被重定向?

最佳答案

您可以创建忽略规则,匹配要忽略的 URL

<rule name="Ignore" enabled="true" stopProcessing="true">
   <match url="^(images|css|bundles).*"/>
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
   <action type="None"/>
</rule>

关于IIS 网址重写 : how to ignore minified javascript and css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17212714/

相关文章:

http - Firefox 在 304 之后不使用缓存的文件副本

c# - ASP.NET Core 2.0 - 部署到 IIS

iis - 使用 URL Rewrite 更改 URL 的一部分

.htaccess - Htaccess : generate 404 error for a partially path

.htaccess - 使用 htaccess 进行简单重定向

ssl - 重写 URL iis 7 - https ://www. somewhere.com -> https ://somewhere. com

azure - 允许远程 Web 服务器管理 Azure 服务器核心 VM

asp.net - 带有 IIS 且没有 Node.js 的 Angular2

windows - 在 IIS 上删除 Codeigniter 的 index.php?

asp.net - Windows 身份验证在 IISExpress 中有效,但在 IIS 中无效