Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is there any way to get full url on server side?

New Here ,
Sep 03, 2009 Sep 03, 2009

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!

2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 03, 2009 Sep 03, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 03, 2009 Sep 03, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 03, 2009 Sep 03, 2009

.I want get full url that request from client side.

<cfset requester_url = cgi.HTTP_REFERER>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 03, 2009 Sep 03, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 04, 2009 Sep 04, 2009

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?

That's right. Test it yourself.

page1.cfm

========

<a href="page2.cfm">page 2</a>

page2.cfm

========

<cfoutput>#cgi.http_referer#</cfoutput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2009 Sep 04, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2009 Sep 08, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources