How does ColdFusion resolve filenames? (stupid question???)

Posted on 2006-03-20
Last Modified: 2013-12-24
Bear with me, I'm new at this (but an experienced programmer).

In the code for a page named send.cfm there is this line:
<cflocation url="view.cfm">
It specifies where to go after inserting a record into a database (if this looks familiar, yes, it's from the tutorial that comes with DreamWeaver).

On my site, the files send.cfm and view.cfm reside in the same subdirectory on the site.
(To be exact, for my test server, they are in c:\CFusionMX7\wwwroot\MyTestSite\contact\coldfusion)

Now instead of going to the view.cfm page after inserting a record, I want to go to another page, named thankyou.html. That file is in the root folder for my site, specifically, it is in c:\CFusionMX7\wwwroot\MyTestSite

I cannot for the life of me figure out how to get it to find the file!
I have tried:
<cflocation url="thankyou.html">  (which I didn't think you work anyways, and it didn't)
<cflocation url="/thankyou.html">
<cflocation url="//thankyou.html">
<cflocation url="#thankyou.html">   (by now I am grasping at straws!)
<cflocation url=".thankyou.html">  

If I open a browser window and type in this address:
I can get to it just fine.

I've tried finding the answer in the Getting Started manual for Dreamweaver and in the help but I'm coming up empty!

If I put the file in c:\CFusionMX7\wwwroot\MyTestSite\contact\coldfusion and use the statement <cflocation url="thankyou.html">  it all works fine, of course! But I don't want to put the file there!)

What the heck is the correct way to tell it to go back to the root to find this file?

Question by:alicia1234
    LVL 15

    Expert Comment

    Try this: <cflocation url="../thankyou.html">  

    Author Comment

    danrosenthal: thanks, but it didn't work. I even checked the code on my test server to be sure the change got up there. Here is exactly what's in the code on the test server (I copied and pasted here):

    <cflocation url="../thankyou.html">

    also tried ./thankyou.html and

    no dice.
    LVL 15

    Expert Comment

    I did some testing and there was some funky caching going on. Try changing the name of the page that contains the CFLOCATION and see if that works (not thankyou.html). I tested the code I posted and you re-posted and verified that it works just fine.

    Author Comment

    I made a copy of the page send.cfm ... the one that contains the CFLOCATION command.
    Then I previewed it in browser ... I still get the file not found thing when it tries to access "../thankyou.html"
    I did verify that my stest server does have "../thankyou.html"

    Author Comment

    Based on your comments, I tried some more things. In the process, I stumbled upon the user interface to change this parameter ... through Applications panel, Server Behaviors ... I double-clicked the item "Insert Record (form1, connAlicia, COMMENTS)" and got to the screen where I could browse for the "After inserting, go to" location.
    I browsed to my thankyou.html file, and Dreamweave resolved it as "../../thankyou.html".
    So I cancelled out and then went in to edit the code for the page to change the statement to
    <cflocation url="../../thankyou.html">
    I did a Preview in Browser and it asked about uploading files and I said to do it.
    I still got the file not found error.
    BUT ... then I went to the Files panel and did a "Put File(s)" from there.
    Then it all worked fine.
    So there does indeed seem to be some funny caching stuff going on.
    However ... it does turn out that the syntax with ../../thankyou.html was the correct one.
    Can you explain why?

    LVL 10

    Accepted Solution


    <cflocation ...> uses absolute and relative URLs rather than physical paths.

    If your page with the cflocation in it is at /CafeAlica_1/contact/coldfusion and the page you want to location to is in /CafeAlica_1 then you either need to go back up 2 folder levels eg ../../  or you need to use /CafeAlica_1, so that it know to redirect to a page in the virtual directory "CafeAlica_1" at the top level of the site.

    <cflocation url="thankyou.html">  would look in the same folder as the calling template
    <cflocation url="/thankyou.html"> would look in the very top level of the site get http://localhost:8500/
    <cflocation url="//thankyou.html"> is invalid, but would probably still look in the top level of the site.
    <cflocation url="#thankyou.html"> would try to go to an anchor called "thankyou.html" in the current page (maybe)
    <cflocation url=".thankyou.html">  would look for a file call ".thankyou.html" in the current folder
    <cflocation url="../thankyou.html"> would look in the folder above the calling template.
    <cflocation url="../../thankyou.html"> looks two folders above the calling template
    <cflocation url="/CafeAlica_1/thankyou.html"> is an absolute path to the template thankyou.html

    Hope this helps


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and Log…
    The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Click on Too…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now