Skip to main content
Inspiring
April 8, 2011
Question

did page request HTTPS or HTTP version of my page ?

  • April 8, 2011
  • 2 replies
  • 660 views

is there a way to check if a page on my site was requested with HTTP or HTTPS ?

I only want to respond if I know the page was requested as:

https://www.mysite.com/mypage.cfm ?

    This topic has been closed for replies.

    2 replies

    Inspiring
    April 8, 2011

    I couldn't find anything on the Coldfusion forum, but I've managed to find something on House Of Fusion.

    Would the following be correct ?

    <cfif #cgi.server_port_secure# EQ 1>

      HTTPS

    <cfelse>

      HTTP

    </cfif>

    expanding it further, is the following also valid ?

    <cfif #cgi.server_port_secure# EQ 1 AND structKeyExists (form,"password")>

      HTTPS

    <cfelse>

    HTTP

    </cfif>

    Participating Frequently
    April 8, 2011

    Better:

    HTTP

    </cfif

    Community Expert
    April 8, 2011

    You can look in the CGI scope to find this and many other things. These may slightly vary from one server to another, as they're dependent on web server software, but there's one called CGI.HTTPS and another called CGI.SERVER_PORT.

    Dave Watts, CTO, Fig Leaf Software

    http://www.figleaf.com/

    http://training.figleaf.com/

    Dave Watts, Eidolon LLC