2

My CFWheels site is running under subfolder/ in the web root, and I have the web.config on the same level as subfolder/. In my web.config I have the necessary URL rewrite rule to remove "subfolder/index.cfm/" from the URL.

My problem arises when I try to include a Javascript file from the default "javascripts" folder using

javaScriptIncludeTag("script.js")

By default, cfwheels looks in /subfolder/javascripts/ for the JS file. However, I've removed subfolder/ from the URL, so a request to /subfolder/javascripts/script.js fails with the following error message:

Wheels.ViewNotFound

Could not find the view page for the javascripts action in the subfolder controller.

Bogus. "javascripts" and "subfolder" are not an action and a controller.

I believe a request to /javscripts/script.js would succeed. How do I tell cfwheels not to look for the javascripts/ folder in subfolder/?

I was unable to find the answer in the documentation, and I haven't gotten any response on the CFWheels Google Group either. I'm looking for an answer such as this, but specific to CFWheels.

edit
IIS 7 web.config rewrite:

<rule name="Remove subfolder/index.cfm">
    <match url="(.*)" />
    <action type="Rewrite" url="/subfolder/index.cfm/{R:0}" />
</rule>

My problem may be here if this rule is incorrect, I'm not sure.

linkTo() actually links to the incorrect path as well.

linkTo(text="Say Hello", controller="say", action="hello")

outputs

<a href="http://mysite.com/subfolder/index.cfm/say/hello">Say Hello</a>
Community
  • 1
  • 1
Riley Watkins
  • 3,453
  • 3
  • 25
  • 19
  • Can you post your URL rewrite file? Are you rewriting to rewrite.cfm? Are calls to linkTo() and such writing the correct URLs? – Chris Peters Mar 24 '11 at 19:32
  • I am not rewriting to rewrite.cfm as the documentation doesn't mention it in regards to IIS 7. I've updated the question with the rewrite rule and the output of linkTo(). – Riley Watkins Mar 24 '11 at 20:01

1 Answers1

1

i think the problem is that you are forgetting to negate the javascript and other folders for cfwheels.

i did i writeup the covered this a while back:

http://rip747.wordpress.com/2009/02/23/cfwheels-url-rewriting-in-a-subfolder/

though this was for a different url rewriter i'm sure you could port the rules to IIS7.

rip747
  • 9,375
  • 8
  • 36
  • 47
  • Ah, so it appears that I should be rewriting to `/subfolder/rewrite.cfm/{R:1}` instead of `/subfolder/index.cfm/{R:1}` (I was wondering what rewrite.cfm was for.) Even after this change, however, linkTo() still generates `http://mysite/subfolder/say/hello`. How do I now remove subfolder from the URL? – Riley Watkins Mar 24 '11 at 23:17
  • Ok, I see now that the default "ColdFusion on Wheels URL Rewriting" rule should do all of the rewriting I need, it just needs to be enabled. This was an oversight on my part, but the site runs great now. However, I would still like to remove `subfolder/` from the URL. Can that be done? – Riley Watkins Mar 25 '11 at 00:25
  • @Riley I think that you would need to configure the server to support multiple sites, then map each site to its dir i.e. site one would go to wwwroot/subfolder1 This way you can directly access the site without "subfolder1" in the url – n_kips Oct 27 '11 at 22:55