?
Solved

GetURL from hte request

Posted on 2002-03-09
16
Medium Priority
?
587 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
[X]
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
  • 5
  • 5
  • 5
  • +1
16 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6854547
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
ID: 6858753
0
 
LVL 1

Expert Comment

by:dawesi
ID: 6858755
0
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.

 

Author Comment

by:simi
ID: 6859011
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
ID: 6859044
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
ID: 6859431
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
ID: 6860348
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
ID: 6860351
sorry...my above had a mixup...the second example should have had cgi.http_host = 131.107.2.1  Sorry for any mixup.
0
 

Expert Comment

by:slingle
ID: 6860360
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
ID: 6861079
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
ID: 6861080

0
 

Author Comment

by:simi
ID: 6861083
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
ID: 6861173
turn your debug on: they're at the bottom.
0
 

Expert Comment

by:slingle
ID: 6861516
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 100 total points
ID: 6861524
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
ID: 6861544
Thanks.
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 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