Solved

GetURL from hte request

Posted on 2002-03-09
16
574 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

806 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