IIS重写url
我不知道如何通过url重写来解决此问题: 遵循此模式的URL app/(*) 应重定向到app/index.cshtml 但是,应用程序文件夹包含子文件夹、js文件和html文件等资源。这些应该被忽略,不应该进行重定向 我是这样做的:IIS重写url,iis,url-rewriting,Iis,Url Rewriting,我不知道如何通过url重写来解决此问题: 遵循此模式的URL app/(*) 应重定向到app/index.cshtml 但是,应用程序文件夹包含子文件夹、js文件和html文件等资源。这些应该被忽略,不应该进行重定向 我是这样做的: <rewrite> <rules> <rule name="Rule 1" stopProcessing="true"> <match url="app/(.*/.js)" />
<rewrite>
<rules>
<rule name="Rule 1" stopProcessing="true">
<match url="app/(.*/.js)" />
<action type="None" />
</rule>
<rule name="Rule 2">
<match url="app/(.*)" />
<action type="Rewrite" url="app/index.cshtml" />
</rule>
</rules>
</rewrite>
我现在只尝试排除js文件,但当我浏览到app/someurl时,我得到一个错误,因为其中一个js文件无法加载。我想那是因为第一条规则不起作用
你能帮忙吗?这就是我最后要做的:
<rule name="Rule1">
<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="\.axd$" />
<add input="{URL}" negate="true" pattern="\.jpg$" />
<add input="{URL}" negate="true" pattern="\.gif$" />
<add input="{URL}" negate="true" pattern="\.png$" />
<add input="{URL}" negate="true" pattern="\.css$" />
<add input="{URL}" negate="true" pattern="\.ico$" />
<add input="{URL}" negate="true" pattern="\.cur$" />
<add input="{URL}" negate="true" pattern="\.js$" />
<add input="{URL}" negate="true" pattern="\.xml$" />
<add input="{URL}" negate="true" pattern="\.svg$" />
<add input="{URL}" negate="true" pattern="\.ttf$" />
<add input="{URL}" negate="true" pattern="\.eot$" />
<add input="{URL}" negate="true" pattern="\.woff$" />
<add input="{URL}" negate="true" pattern="\.html$" />
</conditions>
<action type="Rewrite" url="app/index.cshtml" />
</rule>
在什么情况下应忽略重定向?仅当在子文件夹中并请求js文件或html文件时?在应用程序文件夹以及子文件夹中请求js文件和html文件时,应忽略重定向。请确保如果仅保留前两个条件,它应按预期工作。