Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing index.cfm from url with web config

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!

like image 782
dspz Avatar asked Nov 26 '13 20:11

dspz


1 Answers

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

like image 193
Avery Martell Avatar answered Nov 18 '22 18:11

Avery Martell