Automatically Determine URL and File Path of Application

<!---

  A handy timesaver:
  Place this in your application.cfm file and you will always know the URL and file path to the root of your application.

  Advanced:
  If for some reason, you need to reset, simply pass is "?flush=1" on any site page

--->



<!--- START: Define Global Settings that should only be set-up once --->
<cfif (NOT isdefined("APPLICATION.siteURL")) OR isdefined("URL.flush")>

   <!--- START: Lock so we can define all application variables safely --->
   <cflock scope="APPLICATION" timeout="#CreateTimeSpan(0,0,0,500)#">

       <cfset APPLICATION.siteURL = replace(GetDirectoryFromPath(
"http://"&cgi.server_name& cgi.path_info),"\","")>
       <cfset APPLICATION.file_path = GetDirectoryFromPath(GetCurrentTemplatePath())>


       <!--- Place other APPLICATION definitions here... --->

    </cflock>
    <!--- END: Lock so we can define all application variables safely --->

</cfif>
<!--- END: Define Global Settings that should only be set-up once --->

All ColdFusion Tutorials By Author: Peter Coppinger
Download the EasyCFM.COM Browser Toolbar!