[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Get full url (address bar)

Posted on 2004-04-29
Medium Priority
Last Modified: 2013-12-24

My problem is with the mappings for developping I have access to a local server that has been mapped with a different virtual mapping.

http://mydevserver:theport/eup/ -> https://thednsname/eup/dev/
http://mytestserver:theport/eup/ -> https://thednsname/eup/test/

So If I use to find the path of my pictures the following:
<img src="/eup/images/img1.gif"> this will work locally but not with the mapping done that expect <img src="/eup/dev/images/img1.gif">. I have no choice for the external name.

So I would like put into Application.cfm a script that will get the url that is into the address bar. I define it as "root" and I have no more problems.

I have problems also if I use relatives path (img src="images/img1.gif") as I must be able to access those images from one (or more) lower level ("/eup/sec/index.cfm")

I hope that I am clear.

Question by:maquejph
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +3
LVL 35

Expert Comment

ID: 10950396

I am a little confused about the question and why you need it, but have you looked at the CGI variables?

Here are some that may be of interest

CGI.HTTP_HOST - HTTP host name as sent by the client
CGI.CF_TEMPLATE_PATH - Path of Cold Fusion file being executed
CGI.DOCUMENT_NAME - Complete local directory path of the current document
CGI.DOCUMENT_URI - Local path of the current document relative to the web site base directory
CGI.PATH_INFO - Requested file path information as provided by client
CGI.SCRIPT_NAME - Logical path of script being executed
CGI.RUL - URL base
LVL 17

Expert Comment

ID: 10952351
do one thing ...

set images as a virtual directory [web server]  in root of ur project direcotry ... map it to teh folder "/foldername/images"
now when ur refrencing them - use "/images/imagename.gif" .. no matter where ur file is - this way u will never have to bother abt ur pages being moved or mapping changes from local to online server ...

infact the best deal wld be to have ur images in the root folder - then u wont even need to add the virtual direcotry for "/images" ... as everytime u refer a path starting with a forward slasg "/" it picks up the path from root or finds a virtual direcotry with that name ...

let me know ...


Expert Comment

ID: 10952967
You can use,


to give you the 'base' url of the page being viewed (ie. http://www.mysite.com ), but I don't think that it was you need to solve this.

You can create a virtual mapping to the EUP folder and then you hsould be able to access your images using <img src="/eup/images/imagename.jpg">.

To create the mapping:
Login into the CFAdmin and then under 'Server Settings', click 'Mappings'.
Add the name '/eup' and map it to the physical location of the 'eup' folder.

Im not sure what the details of your situation are, but using mappings is a good way to  access directories that exist outside you web root or on another server.

I hope this helps,

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

LVL 17

Expert Comment

ID: 10954466
Usually you set these variables in the application scope, i.e.

application.info.domain = "www.mydomain.com/";
application.info.webRoot = "mypath/";
application.info.url = application.info.domain & application.info.webRoot;

ALWAYS include a trailing slash, that wau you never have to guess later on.

If these variables are not set yet you could derive them from cgi.server_name and cgi.path_name

I ussually do the following

<cfset request.pathRoot = getDirectoryFromPath(getCurrentTemplatePath())>

<!--- check what phase the application is in --->
<cfset position = reFindNoCase("(development|testing|staging|production)", cgi.path_translated, 1, "true")>
      <cfset request.applicationPhase = mid(cgi.path_translated, position.pos[1], position.len[1])>
            <h1>Application mode could not be found!</h1>
            <strong>You need to set this manually</strong>

And based upon where the application is located I set these environment variables.

Author Comment

ID: 10957024
I will try to be more clear.

I have 2 server, one for development, one for test. The path were the files are located is the same on both server (see PATH_TRANSLATED). This is very easy to move files from the dev server to the test server avoiding modification of the scripts.
When I have requested to have external access to the server, the reverse proxy manager impose me to use a general url.
So they have mapped on the reverse proxy "https://theirreverseproxyname/eup/dev/" for the server that host the development files and "https://theirreverseproxyname/eup/test/" for the server that host the test version of the application.

I have done a workaround in the Application.cfm. I check the REMOTE_ADDR and depending the ip I receive I set a variable ROOT to "/eup/ers" or "/eup/dev/ers". and then I create other variable prefixed by the ROOT to indicate where the are the images/css/js (CSS=#ROOT#"css/" ...)  But this will only work for 1 server.

I am working with relatives path for the moment, but I have problem with my menu that in include into each files (<CFINCLUDE TEMPLATE="includes/top_menu.cfm">) Into my menu I have to call images and the relative path is changing depending on the folder level.
For index.cfm (<CFINCLUDE TEMPLATE="includes/top_menu.cfm">)
<img align="absmiddle" src="images/secure_ssl_lock_tr.gif" border="0" alt="secure">
for public/index.cfm (<CFINCLUDE TEMPLATE="../includes/top_menu.cfm"> should be
<img align="absmiddle" src="../images/secure_ssl_lock_tr.gif" border="0" alt="secure">

The CGI:
CGI.PATH_INFO  <nothing returned>
CGI.PATH_TRANSLATED /ec/product/applic/webroot/extern/sec/SAN/eup/app_ers/index.cfm
CGI.QUERY_STRING  <nothing returned>
CGI.SCRIPT_NAME /eup/app_ers/index.cfm
CGI.REMOTE_ADDR 1xx.1xx.x.59
CGI.REMOTE_HOST 1xx.1xx.x.59
CGI.SERVER_NAME lakota.xx.xxx.xx.xxx
CGI.HTTP_HOST lakota.xx.xxx.xx.xxx:x0x0
CGI.URL  <nothing returned>
CGI.DOCUMENT_URI  <nothing returned>
CGI.DOCUMENT_NAME <nothing returned>
The only difference I receive is the REMOTE_ADDR and REMOTE_HOST

For information, I am learning CFM by myself as I have to wait too long to have the hired cfm developper to come and I have deadline in view. So I am sorry if I am not clear or I have ask "rookie" question
LVL 17

Expert Comment

ID: 10957177
put this in your header of all your pages, if your header is an include this should not be an issue for you
<base href="http://www.yoursite.com/whatever/">

and if your images folder is in the root of your site you can call of them like so
<img src="image/myphoto.gif">

you will never ever have to change the img src again only the base href which as I explained to you above is easily done.

If you use dreamweaver you can easily do a global search and replace if you have to.

If this is still not the solution you are after then its not very clear what exactly you want done.

Author Comment

ID: 10957385
I will try to define better (sorry its is not easy)
Let says that my webserver is running locally. The dev is using port 6000 and the test port 7000.

http://localhost:6000/eup/                       = c:\webroot\eup\
http://localhost:6000/eup/app_ers/          = c:\webroot\eup\app_ers\
http://loaclhost:6000/eup/app_ers/img/   = c:\webroot\eup\app_ers\img\
http://loaclhost:6000/eup/app_ers/inc/    = c:\webroot\eup\app_ers\inc\
http://loaclhost:6000/eup/app_ers/sec/   = c:\webroot\eup\app_ers\sec\
http://loaclhost:6000/eup/app_ers/pub/   = c:\webroot\eup\app_ers\pub\

The organisation here using a reverse-proxy to map to all the webserver. So they have mapped as follow: https://the-reverse-proxy/eup/dev/  = http://localhost:6000/eup/ and https://the-reverse-proxy/eup/test/ = http://localhost:7000/eup/

Now, into my file that are located under "/eup/app_ers/sec/" I call StyleSheet/IMGs/INCs
<link href="../css/style.css" rel="stylesheet" type="text/css">
<img src="../images/outlook_mail.jpg" >
<CFINCLUDE TEMPLATE="../includes/menu_secure.cfm">
without problems. Up to me to provide the right relative path.

I use this include in different folder level.
"/eup/app_ers/pub/index.cfm", "/eup/app_ers/index.cfm", "/eup/app_ers/sec/index.cfm"
So depending on the folder hiearachy where the file tha invoke the INCs the path to the images change => "images/outlook_mail.jpg" or ="../images/outlook_mail.jpg"

So whatever I do on the webserver I am bind to the reverse-proxy urls. If I map to have "/IMG_ERS/" to refers to "/eup/app_ers/img/" this will not work with the reverse proxy.


PS: English is not my mother tongue so it is a little more difficult to explain.
LVL 17

Expert Comment

ID: 10958066
for <CFINCLUDE TEMPLATE="../includes/menu_secure.cfm"> use a mapping you create in CF admin for your other do as I told you above.

Author Comment

ID: 10958409
I have found a workaround...
In each folder I have created an cfg.cfm that I CFINCLUDE on the first line of each page.
So in the "/eup/app_ers/sec/" it contains
<CFSET IMG_LOC="../images/" >
<CFSET CSS_LOC="../css/" >
<CFSET JS_LOC="../js/" >
<CFSET INC_LOC="../includes/" >
<CFSET PUBLIC_LOC="../public/" >
<CFSET REF_DOC_LOC="ref_docs/" >
So in the "/eup/app_ers/pub/" it contains
<CFSET IMG_LOC="../images/" >
<CFSET CSS_LOC="../css/" >
<CFSET JS_LOC="../js/" >
<CFSET INC_LOC="../includes/" >
<CFSET SECURE_LOC="../secure/" >
<CFSET REF_DOC_LOC="ref_docs/" >
So in the "/eup/app_ers/" it contains
<CFSET IMG_LOC="images/" >
<CFSET CSS_LOC="css/" >
<CFSET JS_LOC="js/" >
<CFSET INC_LOC="includes/" >
<CFSET PUBLIC_LOC="public/" >
<CFSET SECURE_LOC="secure/" >

This is solving my problem.

By the way, thank you for your differents suggestions.
LVL 35

Expert Comment

ID: 10960732
You should post a question here :

asking for this question to be PAQ/Refund
LVL 17

Expert Comment

ID: 10963459
that looks like a brilliant work-around, great work, looks like its easy to.... keep it up..

Author Comment

ID: 10966608
Thank you for all your tips.
For the workaround I use; As the path should not be changed and the number of folder that contains pages will not be more than 4, so it will be easy to maintain.

I will do so

Accepted Solution

PashaMod earned 0 total points
ID: 10999710
Closed, 500 points refunded.
I've also removed the unnecessary comments, thanks for the understanding

Community Support Moderator

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 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