重写规则以重写所有EXCEPT文件扩展名 [英] Rewrite Rule to Rewrite All EXCEPT File Extension
本文介绍了重写规则以重写所有EXCEPT文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个规则设置来重写进入子目录的所有内容,如下所示:
I've got a rule setup to rewrite everything going into a subdirectory like so:
<rule name="Forms Directory" stopProcessing="true">
<match url="^forms/(.*)" />
<action type="Redirect" url="forms.htm" redirectType="Permanent" />
</rule>
但是,我想做一些改动,允许它访问表单文件夹中的ASP文件。所以我想保持相同的规则但排除任何.asp匹配规则。我尝试了以下但无法按预期运行:
However, I want to make a slight change to allow it to access an ASP file in the forms folder. So I want to keep the same rule but exclude any .asp from matching the rule. I tried the following but couldn't get it to operate as expected:
<rule name="Forms Directory" stopProcessing="true">
<match url="^forms/(.*)[^(.asp)]" />
<action type="Redirect" url="forms.htm" redirectType="Permanent" />
</rule>
非常感谢任何帮助!
推荐答案
检查文件扩展名的其他条件解决了这个问题。
An additional condition that checks file extension solves this.
<rule name="Forms Directory">
<match url="^forms/(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern=".+\.asp$" negate="true" />
</conditions>
<action type="Rewrite" url="forms.htm" redirectType="Permanent" />
</rule>
这篇关于重写规则以重写所有EXCEPT文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文