Removing index.cfm from url with web config

前端 未结 2 1449
春和景丽
春和景丽 2021-01-18 12:31

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

相关标签:
2条回答
  • 2021-01-18 13:12

    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

    0 讨论(0)
  • 2021-01-18 13:16

    Try adding this rewriting rule:

        <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>
    
    0 讨论(0)
提交回复
热议问题