首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重写以隐藏IIS 8中的默认文档

重写以隐藏IIS 8中的默认文档
EN

Stack Overflow用户
提问于 2017-07-29 22:23:39
回答 1查看 353关注 0票数 0

我有一个网站,它使用index.cfm作为整个站点的默认页面。Varibles在url中传递为由正斜杠分隔的值部分。

示例:

代码语言:javascript
复制
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

我想“隐藏”index.cfm在网址,但它仍然有效。

我尝试使用我发现的许多不同的规则(最新的存在)。

代码语言:javascript
复制
<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这样的所有文件中。

代码语言:javascript
复制
        <rules>
            <rule name="Default Document">
                <match url="\/(.*)" />
                <action type="Rewrite" url="index.cfm{R:0}" />
            </rule>
        </rules>

所以,虽然我离得越来越近,但我并不完全在那里。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-30 05:24:53

这个重写规则将为您做到这一点:

代码语言:javascript
复制
<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_Vipwww.domain.com/index.cfm/show_register/memberType_Buyer/membershipLevel_Vip

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45394619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档