Removing index.cfm from web config url

quick question -

My urls currently look like this: index.cfm/camp/another-test

I would like them to look like this: camp/another-test

I can do it perfectly on apache with my .htaccess, but I need to be able to do it on iis7 using web.config. Here I 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!

+6
source share
2 answers

I believe CFWheels requires that you route rewrite requests through rewrite.cfm not index.cfm.

See Chris Peters comment on this

If you configure:

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

in

 <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 if you have:

 <cfset set(URLRewriting = "On")> 

in / config / settings.cfm

+1
source

Try adding this rewrite 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> 
-1
source

Source: https://habr.com/ru/post/958881/


All Articles