使用 web 配置从 url 中删除 index.cfm [英] Removing index.cfm from url with web config
问题描述
快速问题 -
目前我的网址是这样的:index.cfm/camp/another-test
我希望它们看起来像这样:camp/another-test
我可以用我的 .htaccess 在 apache 上做这件事,但我需要能够在 iis7 上用 web.config 来做.到目前为止,这是我的重写:
<规则><rule name="Remove index.cfm" enabled="true"><match url="^(.*)$" ignoreCase="true"/><conditions logicalGrouping="MatchAll"><add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)"/></条件><action type="Rewrite" url="/index.cfm/{R:1}"/></规则></规则></rewrite>
感谢您的帮助!
我相信 CFWheels 要求您通过 rewrite.cfm 而不是 index.cfm 路由重写请求.
请参阅 Chris Peters 对此问题的评论>
如果你调整:
<规则><rule name="Remove index.cfm" enabled="true"><match url="^(.*)$" ignoreCase="true"/><conditions logicalGrouping="MatchAll"><add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)"/></条件><action type="Rewrite" url="/index.cfm/{R:1}"/></规则></规则></rewrite>
到:
<规则><rule name="ColdFusion on Wheels URL Rewriting" enabled="true"><match url="^(.*)$" ignoreCase="true"/><conditions logicalGrouping="MatchAll"><add input="{SCRIPT_NAME}" matchType="Pattern" ignoreCase="true" negate="true" pattern="^/(flex2gateway|jrunscripts|cfide|CFFileServlet|cfformgateway|railo-context|files|images|javascripts|杂项|样式表|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$)"/></条件><action type="Rewrite" url="/rewrite.cfm/{R:1}"/></规则></规则></rewrite>
它应该可以解决您的问题,前提是您:
在/config/settings.cfm
quick question -
Currently my urls look like this: index.cfm/camp/another-test
I would like for them to look like this: camp/another-test
I'm able to do this fine on apache with my .htaccess but I need to be able to do it on iis7 with the web.config. Here's my rewrite so far:
<rewrite>
<rules>
<rule name="Remove index.cfm" enabled="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:1}" />
</rule>
</rules>
</rewrite>
Thanks for the help!
I believe CFWheels requires that you route rewrite requests through rewrite.cfm not index.cfm.
See the comment by Chris Peters on this question
If you adjust:
<rewrite>
<rules>
<rule name="Remove index.cfm" enabled="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:1}" />
</rule>
</rules>
</rewrite>
to:
<rewrite>
<rules>
<rule name="ColdFusion on Wheels URL Rewriting" enabled="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{SCRIPT_NAME}" matchType="Pattern" ignoreCase="true" negate="true" pattern="^/(flex2gateway|jrunscripts|cfide|CFFileServlet|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$)" />
</conditions>
<action type="Rewrite" url="/rewrite.cfm/{R:1}" />
</rule>
</rules>
</rewrite>
it should solve your problem, provided you have:
<cfset set(URLRewriting = "On")>
within /config/settings.cfm
这篇关于使用 web 配置从 url 中删除 index.cfm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!