Re: How to find base URL of an application?
Jason - Thanks but I need it to be more than just the server name. I need it to figure out where it is even if it's a few directories down from the root. In the end, what I decided to do what move my logic out of the init code for application.cfc and into the OnApplicationStart code where I have access to the CGI structure. I then do this: application.rootURLPath = GetDirectoryFromPath(CGI.SCRIPT_NAME); It seems to work so far. Curious if anyone sees any gotchas. Thanks, Dave ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334394 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How to find base URL of an application?
Try this (you don't need the middle bit if you never use SSL): On 6/8/2010 6:28 PM, Dave Burns wrote: > In my Application.cfc's init code, I'm trying to set a variable in the > application scope that is the base URL for the pages in the app. I need this > to overcome some issues later with relative and absolute paths (using CF7 so > app-specific mappings not possible). I'm having some trouble calculating this > robustly and I wonder if I'm overlooking something simple. > > It's easy to get the base file path. I just use: this.rootFilePath = > GetDirectoryFromPath(GetCurrentTemplatePath()); > > But then I want to calc this.rootURLPath. So if the application is located in > the docroot (e.g. d:/inetpub/mysite/), I'd just get '/'. If it were located > elsewhere (e.g. d:/inetpub/mysite/a/b/c/), I'd get '/a/b/c/'. > > I can't use any of the CGI variables because at this point, we're not in the > middle of an HTTP request. What I want is the string overlap between > rootFilePath and CGI.script_name. > > Any ideas? > > > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334393 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
How to find base URL of an application?
In my Application.cfc's init code, I'm trying to set a variable in the application scope that is the base URL for the pages in the app. I need this to overcome some issues later with relative and absolute paths (using CF7 so app-specific mappings not possible). I'm having some trouble calculating this robustly and I wonder if I'm overlooking something simple. It's easy to get the base file path. I just use: this.rootFilePath = GetDirectoryFromPath(GetCurrentTemplatePath()); But then I want to calc this.rootURLPath. So if the application is located in the docroot (e.g. d:/inetpub/mysite/), I'd just get '/'. If it were located elsewhere (e.g. d:/inetpub/mysite/a/b/c/), I'd get '/a/b/c/'. I can't use any of the CGI variables because at this point, we're not in the middle of an HTTP request. What I want is the string overlap between rootFilePath and CGI.script_name. Any ideas? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334381 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm