We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

CF standalone server mapping problem

brucecrabtree
on
Medium Priority
183 Views
Last Modified: 2013-12-24
I use CFMX7 standlone server locally for testing. My problem is that it does not properly recognize site roots. I have set up this mapping for the root in the CF administrator:

Logical path: /

Directory path: C:\CFusionMX7\wwwroot

Everything works fine when I use relative paths in my sites. But CF does not find absolute paths correctly.

So if I try to use this link in mysite1, for example:

<a href="/index.cfm">link</a>

I get this: http://localhost:8500/index.cfm

When I need this: http://localhost:8500/mysite1/index.cfm

I have located the files for mysite1 in c:\cfusionmx7\wwwroot\mysite1

This happens with all my CF sites. It's driving me crazy. I have used a workaround in the past by declaring #application.rootfolder# in Application.cfc and then adjusting the value for the testing and production servers, but for the site I'm working on now it's not feasible. I want to use a number of included files, including an included header and footer placed by Application.cfc, and it's way too complicated to keep using this workaround. The absolute URLs work on my production server, but obviously I need to be able to test and debug locally.

I'm running Windows 2000 locally. The production server is Windows 2003. Don't know if that makes a difference.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
I have never used the cfmx standalone server, but it seems to me that someone said once that they setup different sites under it.
Then of course you'd setup site1's home directory as C:\CFusionMX7\wwwroot\site1
and site2 as C:\CFusionMX7\wwwroot\site2 etc
Then your link "/index.cfm" will work.

Look for this in your cf admin settings

I'll post back if I find more info

Author

Commented:
Yes, I have multiple sites defined within the wwwroot folder. The problem is that it's not correctly finding root-relative links within any of those sites (I said absolute above -- should have said root-relative).
CERTIFIED EXPERT

Commented:
What does it say under site1 (for ex) Home Directory? This is important.
Also, Do you have your application name (in your cfapplication tag) set to a unique value for all sites?

Author

Commented:
>>>What does it say under site1 (for ex) Home Directory? This is important.

I'm not sure what you mean by this. Are you asking about something in the CF admin?  

Yes, I have a unique application name set up for each site.
CERTIFIED EXPERT

Commented:
Yes - in the cf admin ??? I imagine - somewhere
As I said I've never used the standalone server.
On IIS you simply open site properties and on the Home Directory tab - you specify the path to the site.
It must be something like this.

Author

Commented:
There is no similar setting in the CF administrator as far as I can see. You're simply supposed to set a mapping for the web root and then place each site in its own folder in that directory.
CERTIFIED EXPERT

Commented:
OK - Well that is the problem.
There needs to be some way to differentiate one site from another.
a link or include can only define "/index.cfm" (for ex.) as being in relation to something.
A webserver defines it as being in the top level folder of the website in question.
This could simply be a limitation of using the standalone server.

You had mentioned using a localpath var - you might want to reexplore that if there isn't a way to create different sites.
Except that don't make it an application var - just create a var named localPath (for ex)
cfset localPath="/mysite1"
and use it like
a href="#localPath#/index.cfm"
When application hits a real server and your application resides in the website top directory then all you need to change is
cfset localPath=""
and use it like
a href="#localPath#/index.cfm" which is the same as before

This method may actually come in handy for you someday.
You can then write code for sale where the purchaser can simply copy & paste your folder into their site and set their own localPath.

Or whatever ...

good luck

Author

Commented:
That is essentially what I've done. I just set  the variable once, in Application.cfc, and called it application.rootfolder. But it's too much of a headache in the project I'm working on now to add #application.rootfolder# in front of every url. Maybe it is simply a limitation of the standalone server -- except, I tried setting the web root to the specific site's directory, but it still won't work. So I think I'm missing something.
CERTIFIED EXPERT

Commented:
Is this change something that requires a restart of CF?

Shorten your var - change to something unique like "locP"
Do an extended search for that 4 letter string anywhere in your app beforehand to avoid searching problems in the future.
And like I said - take it out of the application scope. just make it a var as in
<cfset locP="/yourpath">
Put this in your Application.cfc and you're off and running.

You don't (or shouldn't) have to put in on every url or include.
Only those that are not in the top level dir and where you need the application to know that the linked to file is in the top level directory

good luck

Author

Commented:
I understand what you're saying, and I've done that before on other projects. But the site I'm working on now is too complex for that. It has a large js menu system with internal icons, and many folders and subfolders. So it would require placing the variable in front of lots and lots of links, not only to page files but also to images, stylesheets, and js files -- in short, it's too much of a headache, and it feels like something I shouldn't have to do. Root-relative links should work! I may have to resort to reinstalling CF -- maybe that will help. Anyway, thanks for your suggestions. I'll keep looking to see what's keeping the CF standalone server from getting those links right.
CERTIFIED EXPERT

Commented:
That actually is the best idea.
Maybe it is a faulty install???
I just suggested this because you had done similar and I thought that there is a possibility that thats just the way it is.

Does the port you're using have any affect? Can you switch to port 80? Just to experiment.
CERTIFIED EXPERT

Commented:
Are you still having trouble here?

Author

Commented:
I've posted this question in a few forums, and what I'm hearing is that this is simply a limitation of the CF built-in server. So for now I am just using the <base> HTML tag as a workaround, although it is a less desirable option than using root-relative links. What I need to do for the long term is to set up my CF development server to work with IIS instead of using the built-in server. Thanks for your suggestions.
CERTIFIED EXPERT
Commented:
Anytime Bruce
I consider myself lucky to have a full-blown development environment - complete with DNS!
There is no other way to develop.

I would appreciate the points on this one, cause I did say that this may be a limitation of the built in server,
but it's up to you.

Good luck

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Done. Thanks agian.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.