Solved

GetURL from hte request

Posted on 2002-03-09
16
565 Views
Last Modified: 2013-12-24
I need to get the url base exactly as entered in the request that came to the server.
For ex.
If the url was http://localhost/index.cfm I need to get the http://localhost out of it.
I can tokenize it myself to get the base, but I don't know how you get the URL.
I can't use cgi.server_name as it gives me the DNS name  of the host. The user might enter it as a "localhost" or asa a ip_adress and I need to use it the same way, otherwise the session variables will not be avaialble.

Thanks.
0
Comment
Question by:simi
  • 5
  • 5
  • 5
  • +1
16 Comments
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
The only way I know how to get what is in the location part of the browser is using JavaScript.

window.location.hostname

check out:
http://java.areco.cz/manual/objects/location.htm
0
 
LVL 1

Expert Comment

by:dawesi
Comment Utility
0
 
LVL 1

Expert Comment

by:dawesi
Comment Utility
0
 

Author Comment

by:simi
Comment Utility
GCI.Server_name is returning the DNS name of the server.
I don't want this.

Say the DNS name is www.foo.com
I will allways get the www.foo.com as a server name.

But the user can use http://localhost or http://123.123.123.123

I want to be able to reconstruc the URL, using exactly the same server name that the user used.
Otherwise, I can have problems with the Session variables.
That happens also in java Servlets.
So the best way , I found, is to tokenize the server name from the URL typed by the user, and reconstruct the URLs using this  value.
0
 
LVL 1

Expert Comment

by:dawesi
Comment Utility
Server_Name will return localhost, 127.0.0.1 or whatever you use? I'm not completely sure what you are talking about?

Do you want the server_name to be www.foo.com even if they use 127.0.0.1 or localhost?
0
 
LVL 1

Expert Comment

by:dawesi
Comment Utility
Answer 1)
Put the tag below in the submitting form:
<INPUT TYPE="hidden" NAME="Request" VALUE="x">
and use:
#ListFirst(GetDirectoryFromPath(Form.Request),'\')#
in your processing page

Answer 2)
Use the http_referer property...
(This will cause issues in IE5.5 and IE6.x)
<CFParam NAME="HTTP_Referer" DEFAULT="">
#ListFirst(GetDirectoryFromPath(HTTP_REFERER),'\')#
0
 

Expert Comment

by:slingle
Comment Utility
just use cgi.http_host.  it is set to whatever the user enters (without the http) example: if the enter http://localhost/index.cfm, cgi.http_host = localhost, if they enter http://131.107.2.1/index.cfm, cgi.http_host = 127.0.0.1.

I tried to comment to this the other day, but Experts Exchange seemed to be having problems...Isn't that a kicker :-)
0
 

Expert Comment

by:slingle
Comment Utility
sorry...my above had a mixup...the second example should have had cgi.http_host = 131.107.2.1  Sorry for any mixup.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:slingle
Comment Utility
sorry...my above had a mixup...the second example should have had cgi.http_host = 131.107.2.1  Sorry for any mixup.
0
 

Author Comment

by:simi
Comment Utility
The answer came from slingle. I want to assign it the points.

However, I need also to konw where can I find those cgi.xxx
variable names. Nothing in the Cold Fusion help about those.
Like, cgi.server_name, cgi.http_host and so on.

0
 

Author Comment

by:simi
Comment Utility

0
 

Author Comment

by:simi
Comment Utility
The answer came from slingle. I want to assign it the points.

However, I need also to konw where can I find those cgi.xxx
variable names. Nothing in the Cold Fusion help about those.
Like, cgi.server_name, cgi.http_host and so on.
0
 
LVL 1

Expert Comment

by:dawesi
Comment Utility
turn your debug on: they're at the bottom.
0
 

Expert Comment

by:slingle
Comment Utility
I don't know where it is in the docs.  Like dawesi said, enable debugging for your IP address and they will show up at the bottom.  OR if you have cold fusion 5 you can create a page and throw <cfdump var="cgi"> on it and that will show you the whole cgi. scope.
0
 

Accepted Solution

by:
slingle earned 25 total points
Comment Utility
just use cgi.http_host.  it is set to whatever the user enters (without the http) example: if the enter
http://localhost/index.cfm, cgi.http_host = localhost, if they enter http://131.107.2.1/index.cfm, cgi.http_host = 131.107.2.1.
0
 

Author Comment

by:simi
Comment Utility
Thanks.
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

10 Experts available now in Live!

Get 1:1 Help Now