6

快速提问 -

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

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

我可以用我的 .htaccess 在 apache 上做到这一点,但我需要能够在 iis7 上用 web.config 做到这一点。到目前为止,这是我的重写:

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

谢谢您的帮助!

4

2 回答 2

1

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

请参阅 Chris Peters对此问题的评论

如果你调整:

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

于 2013-11-26T20:53:49.217 回答
-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>
于 2015-01-13T17:42:03.600 回答