重写以隐藏IIS 8中的默认文档
我有一个网站使用index.cfm作为整个网站的默认页面。变量在url中作为值PAR传递,值PAR由正斜杠分隔 例如:重写以隐藏IIS 8中的默认文档,iis,url-rewriting,web-config,Iis,Url Rewriting,Web Config,我有一个网站使用index.cfm作为整个网站的默认页面。变量在url中作为值PAR传递,值PAR由正斜杠分隔 例如: 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_it
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
我想在url中隐藏index.cfm,但它仍然有效
我尝试过使用许多不同的规则,我发现最新的规则是
<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>
所以,虽然我越来越近了,但我还不太清楚 此重写规则将为您做到这一点:
<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我尝试了此操作,但收到HTTP错误500.19-内部服务器错误无法访问请求的页面,因为页面的相关配置数据无效。如果我试图在IIS中启动站点重写,我会在使用web.config路径udidnt安装URL重写模块执行操作时出错。请尝试安装:我确实安装了它。我在问题中添加了一些屏幕截图,以便您可以更好地了解我所看到的内容。@Lance我编辑了我的答案,并没有忽略css和js文件。我应该为你工作
<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>