Is there any way to get full url on server side?
Copy link to clipboard
Copied
Hi guys:
Is there any way to get full url on codefusion.I have googed but get nothing help.I want get full url that request from client side.eg: 'http://www.***.com'
Actually i need the http:// or https from url.
Dose anybody can help me.Thank you!
Copy link to clipboard
Copied
Take a look at the variables in the CGI scope. You can use CGI.SERVER_PORT to determine if port 443 (https) was used.
"CGI environment (CGI Scope) variables"
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Expressions_8.html#2679705
Copy link to clipboard
Copied
Thank you for your quick response.
For some reason,We can't use cgi.server_port to get whether the request is a http or https,because we have installed a loadbalance and on Web Server cgi.server_port always equal 80.So I think if i can get the full current url,i can http or https from url.
Copy link to clipboard
Copied
.I want get full url that request from client side.
<cfset requester_url = cgi.HTTP_REFERER>
Copy link to clipboard
Copied
Hi,BKBK.
First, thank you for your quick response.
Is cgi.HTTP_REFERER can get the CURRENT full url ?I think it can only get the url redirected to the current page,I mean if i browser
from http://****.com/a.cfm and click a link to http://****.com/b.cfm, In b.cfm if i use cgi.HTTP_REFERER,i will get http://****.com/a.cfm. Is it right?
Actually,I'm really want to get the CURRENT full url for judge whether the request is http,If the request is http,I want re-redirect to https.But caused by the loadbalance,all value get by cgi.server_port are 80 including https request.
Copy link to clipboard
Copied
Is cgi.HTTP_REFERER can get the CURRENT full url ?I think it can
only get the url redirected to the current page,I mean if i browserfrom http://****.com/a.cfm and click a link to http://****.com/b.cfm, In b.cfm if i use cgi.HTTP_REFERER,i will get http://****.com/a.cfm. Is it right?
That's right. Test it yourself.
page1.cfm
========
<a href="page2.cfm">page 2</a>
page2.cfm
========
<cfoutput>#cgi.http_referer#</cfoutput>
Copy link to clipboard
Copied
cgi.http_referrer does not give you the current url. It gives you the page that contained the link/form/whatever that got you to the current page. If the page was requested via a bookmark, or by typing the url into the address bar, or something like that, it will be blank.
Given your load balancing situation, I'm not sure if you can figure out which page requests are http and which are https.
Copy link to clipboard
Copied
Thank you guys for responsing my question.
We use haproxy for loadbalancing and all ssl cert file are installed on loadbalancing server.All requests gose throught loadbalancing to Web Server.
The requests between loadbalacing and web server are http.So we can't use cgi.server_port to judge if the request is http or https from customer client.
Finally we GetHttpRequestData().headers["X-Forwarded-For"] to get the requests IP Address .If the IP is we loadbalancing server IP then we think it as https request,otherwise we think it as http request.And it works now.

