Skip to main content
Participant
September 3, 2009
Question

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

  • September 3, 2009
  • 2 replies
  • 2301 views

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!

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    September 3, 2009

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

    <cfset requester_url = cgi.HTTP_REFERER>

    JoesphiAuthor
    Participant
    September 4, 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.

    BKBK
    Community Expert
    Community Expert
    September 4, 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>

    Inspiring
    September 3, 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

    JoesphiAuthor
    Participant
    September 4, 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.