使用web配置从url中删除index.cfm

时间:2013-11-26 20:17:33

标签: iis-7 coldfusion url-rewriting web-config cfwheels

快速提问 -

目前我的网址如下:index.cfm/camp/another-test

我希望他们看起来像这样:camp/another-test

我可以使用我的.htaccess在apache上做得很好,但是我需要能够使用web.config在iis7上完成。到目前为止,这是我的重写:

<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>

感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

我相信CFWheels要求您通过rewrite.cfm而不是index.cfm路由重写请求。

请参阅Chris Peters的评论on this question

如果你调整:

<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>

为:

<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>

它可以解决您的问题,前提是您:

<cfset set(URLRewriting = "On")>

在/config/settings.cfm

答案 1 :(得分:-1)

尝试添加此重写规则:

    <rewrite>
      <rules>
        <rule name="ColdFusion on Wheels URL Rewriting" enabled="true">
          <match url="^(.*)$" ignoreCase="true" />
          <conditions logicalGrouping="MatchAll">
            <add input="{SCRIPT_NAME}" negate="true" pattern="^/(flex2gateway|jrunscripts|cfide|CFFileServlet|cfformgateway|railo-context|files|images|javascripts|miscellaneous|newsletters|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$)" />
          </conditions>
          <action type="Rewrite" url="/rewrite.cfm/{R:1}" />
        </rule>
      </rules>
    </rewrite>