重写以隐藏 IIS 8 中的默认文档
Rewrite to hide default doc in IIS 8
我有一个站点使用 index.cfm 作为整个站点的默认页面。变量在 url 中作为由正斜杠分隔的值解析传递。
示例:
www.domain.com/index.cfm/show_register/memberType_Buyer/membershipLevel_Vip
www.domain.com/index.cfm/show_register/memberType_seller/membershipLevel_Standard
www.domain.com/index.cfm/show_items/category_bike/id_123
我想 "hide" index.cfm 在 url 但它仍然有效。
我已经尝试使用我发现的许多不同规则(最新的规则)
<rewrite>
<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>
</rewrite>
但我似乎无法让它正常工作。我觉得因为 index.cfm 是我可能处于某种无限循环中的站点的默认文档。
我哪里错了?
更新:
我已经安装了重写。
这就是我在 IIS 中看到的
这是浏览器显示的内容
我确实让这个重写工作,但现在它正在向所有内容添加 "index.cfm",包括像 /js/global.js
和 /css/site.css
这样的文件
<rules>
<rule name="Default Document">
<match url="\/(.*)" />
<action type="Rewrite" url="index.cfm{R:0}" />
</rule>
</rules>
所以虽然我越来越近了,但我还没有到那儿。
此重写规则将为您做到这一点:
<rule name="Default Document" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{PATH_INFO}" pattern="^/index.cfm" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:0}" />
</rule>
它将重写个请求:
www.domain.com/show_register/memberType_Buyer/membershipLevel_Vip
到 www.domain.com/index.cfm/show_register/memberType_Buyer/membershipLevel_Vip
我有一个站点使用 index.cfm 作为整个站点的默认页面。变量在 url 中作为由正斜杠分隔的值解析传递。
示例:
www.domain.com/index.cfm/show_register/memberType_Buyer/membershipLevel_Vip
www.domain.com/index.cfm/show_register/memberType_seller/membershipLevel_Standard
www.domain.com/index.cfm/show_items/category_bike/id_123
我想 "hide" index.cfm 在 url 但它仍然有效。
我已经尝试使用我发现的许多不同规则(最新的规则)
<rewrite>
<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>
</rewrite>
但我似乎无法让它正常工作。我觉得因为 index.cfm 是我可能处于某种无限循环中的站点的默认文档。
我哪里错了?
更新:
我已经安装了重写。
这就是我在 IIS 中看到的
这是浏览器显示的内容
我确实让这个重写工作,但现在它正在向所有内容添加 "index.cfm",包括像 /js/global.js
和 /css/site.css
<rules>
<rule name="Default Document">
<match url="\/(.*)" />
<action type="Rewrite" url="index.cfm{R:0}" />
</rule>
</rules>
所以虽然我越来越近了,但我还没有到那儿。
此重写规则将为您做到这一点:
<rule name="Default Document" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{PATH_INFO}" pattern="^/index.cfm" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:0}" />
</rule>
它将重写个请求:
www.domain.com/show_register/memberType_Buyer/membershipLevel_Vip
到 www.domain.com/index.cfm/show_register/memberType_Buyer/membershipLevel_Vip