Reply to topic
SSL Question
eriweb


Joined: 06 Apr 2004
Posts: 68
Reply with quote
Hello all,

When a user navigates to my site and if they are not using https I would like to programmatically with coldfusion add the https instead of them seeing the You must use a secure channel https:// error.

Can anyone please help?

Thanks.
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 547
Location: Harrisburg, PA
Reply with quote
What you need to do, is check the CGI.SERVER_Port.

On a standard HTTP page, it will report the port as 80. But when you are within HTTPS, it will report the port as 443. So In your application. CFC or cfm file you can do something like this:

Say you want to secure your checkout:

Code:

<cfif CGI.Script_Name Contians "/Shopping/Checkout/" AND CGI.Server_Port EQ 80>
    <cflocation url="https://www.mydomain.com/Shopping/Checkout/">
</cfif>


There are other more efficient ways of doing this rather than checking directories and filenames everytime and redirecting.

Hope this helps

Smile
Connie


Joined: 26 Mar 2005
Posts: 176
Location: The Internet
Reply with quote
I dealt with something like this recently, first, set it up in IIS so that only https connections were allowed, then configured a custom 403 error that would redirect the user.

Code:

<%
 Data = request.servervariables("QUERY_STRING")
 URL = replace(Data, "403;", "")
 URL = replace(URL, "http://", "https://")
 response.Status = "200 OK"
 response.redirect URL
%>   
SSL Question
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic