Setting Mappings on a ColdFusion Site

 
May 28, 2001
Dov B. Katz, Chairman and CEO of the Morningside Internet Group, Inc., recently posted an interesting explanation of this intricate task on the NYCFUG mailing list, in response to the question, "When mapping drives on a ColdFusion site, does mapping need to be done in both web server (I am using Personal Web Server on Win 98 and Internet Information Server 4 on Win NT Server 4) and in ColdFusion (using CF Express locally and CF 4.5 on web server)?":

Mappings in CF are different from mappings in IIS/PWS.

In IIS and PWS, you can set up Mysite.com/myFolder to point to some random folder on the C: drive. This allows you to have "virtual directories" and make a website tree that does not necessarily resemble your Hard Drive.

On the other hand, CF mappings are used for a different purpose. You can set them up to make Absolute paths to templates used when CFIncluding and CFModuling.

I.e.: You have some big CF application, and all pages should use the same look-and-feel template. In such a case (especially good for Fusebox and the like), wouldn't it be nice to have a way of including files from other folders, without calculating the relative path to that folder? Say you are in www.mysite.com/folder1/folder2/folder3/index.cfm and you want to include a file in the www.mysite.com/resources folder.

Do you honestly want to try typing CFINCLUDE template="../../../resources/MyHeaderAndFooter.cfm" ?

What happens if you move things around? That is like asking for a disaster! Therefore, set up a mapping which maps, say "/Site_Resources" To C:\inetput\wwwroot\Resources (for example), Then, wherever you want to include that file, simply write: <CFINCLUDE | CFMODULE TEMPLATE="/Site_Resources/MyHeaderAndFooter.cfm"> No more recalculation of paths when you move things around!

=====TO SUM THINGS UP====

Mappings, in both IIS/PWS and CF, are used after the folder requested, could not be physically found. CF looks for folders when compiling code to execute. IIS/PWS looks for folders when retrieving files to send to the browser.

In the sequence of events that a server follows (this is very high level!):

1) WEBSERVER processes request of file /FolderX/INDEX.CFM
2) WEBSERVER looks for FolderX inside its wwwroot folder
3) WEBSERVER finds c:\inetpub\wwwroot\FolderX
4) WEBSERVER FINDS file INDEX.CFM in folder FOLDERX
5) WEBSERVER realizes that it is a cfm and asks CF to read it
6) CFSERVER reads INDEX.CFM
7) CFSERVER discovers that index.cfm wants to include FolderY/a.cfm
8) CFSERVER Looks for a FolderY inside FolderX
9) etc. ...

You can see here that IIS/PWS mappings affect Step 2, and CF Mappings affect Step 8. That's the best way I can explain it.


Privacy | FAQ | Site Map | About | Guidelines | Contact | Advertising | What is ColdFusion?
House of Fusion | ColdFusion Jobs | Blog of Fusion | AHP Hosting