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
Solved

GetURL from hte request

Posted on 2002-03-09
16
577 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 25 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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