通过IIS URL重写删除index.cfm

时间:2014-11-14 18:13:08

标签: iis coldfusion iis-7 iis-7.5 coldfusion-10

如果没有query_string,我想删除URL中的index.cfm www.mysite.com/index.cfm会被重写为www.mysite.com'www.mysite.com/Test/index.cfm会被重写为'www.mysite.com/Test/,但如果网址中有querstring,则url不会受到影响,例如'www.mysite.com/Test/index.cfm?u=5不会受到重写规则的影响。

我怎样才能得到它?

1 个答案:

答案 0 :(得分:1)

这对我来说非常适合

<rule name="Default Document" stopProcessing="true">
    <match url="(.*)index.cfm" />
    <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
        <add input="{PATH_INFO}" pattern="^.*(/index.cfm/).*$" negate="true" />
        <add input="{QUERY_STRING}" pattern=".+" ignoreCase="false" negate="true" />
    </conditions>
    <action type="Redirect" url="{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>