gpt4 book ai didi

javascript - IIS url 重写 - css 和 js 被错误地重写

转载 作者:数据小太阳 更新时间:2023-10-29 05:27:16 29 4
gpt4 key购买 nike

我的 urlrewrites 有问题 - 每当我指向要重写的页面时,它都无法显示,因为它还将规则应用于我网页中引用的 css 和 js 文件。

为了尝试解决这个问题,我在 css 和 js 中加入了一个完全合格的路径 - 当我尝试访问浏览器挂起的重写页面时,这在任何尚未应用重写的页面上都可以正常呈现。

有没有人遇到过类似的事情,如果有,你有解决办法吗?感谢任何帮助。尝试在网站上查看类似问题,但到目前为止没有任何帮助。

<rewrite>
<outboundRules>
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1" stopProcessing="true">
<match filterByTags="A, Form, Img" pattern="^(.*/)myapplicationname/Index\.html\?team=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}team/{R:2}/" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^myapplicationname/Index\.html$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^([^=&amp;]+)=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="Index.html?{R:1}={R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>

在我的网页中:

<script src="/myapplicationname/Scripts/jquery-1.4.1.js" type="text/javascript">    </script>
<link href="/myapplicationname/Styles/MainStyle.css" rel="stylesheet" type="text/css" />

它正在对这些应用重写并尝试查找/myapplicationname/Team/Styles/MainStyle.css 以及与 JS 文件类似的内容。

最佳答案

通过一条一条地删除规则来找出导致问题的规则。现在为该规则添加一个条件:

    <rule name="Some rule">
...
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v)$" negate="true" />
</conditions>
</rule>

这将避免在以 .j​​s、.css 等结尾的文件上运行规则

关于javascript - IIS url 重写 - css 和 js 被错误地重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7628519/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com