From: "Westin, Ken" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, April 19, 2004 5:14 PM
Subject: Http to https redirect
>
> OK so I have an application which I only want people to connect to using
> SSL, so I want to have it so that if anyone comes to a particular
> directory from http://www.mydomain.com/myapplication/
>
> To be redirected to:
>
> https://secure.mydomain/myapplication/
>
> I know how to do this with Apache, but am hoping I can do it with CF in
> the Application.cfm file.
It may depend a little on the particular cgi variables available to you,
but on our IIS5/CF5 servers, there's a cgi.https value ("on" or "off")
always available that can be tested.
If you want to rewrite arbitrary page requests rather than just requests
to the index file then you'll have to rewrite the url and append any url
variables. The following will rewrite requests to both
"http://www.domain.com/..." and "http://domain.com/..." as well as to
"http://secure.domain.com/..." (with no host name change in the last
case).
<cfif cgi.https is "off">
<!--- Rewrite the host name --->
<cfset firstpart = ListFirst(cgi.host, ".")>
<cfif firstpart is "www">
<cfset newurl = ReplaceNoCase(cgi.host, "www", "secure", "one")>
<cfelseif firstpart is "secure">
<cfset newurl = cgi.host>
<cfelse>
<cfset newurl = "secure." & cgi.host>
</cfif>
<!--- Add page path --->
<cfset newurl = newurl & cgi.path_info>
<!--- Add query string, if one exists --->
<cfif Len(cgi.query_string)>
<cfset newurl = newurl & "?" & cgi.query_string>
</cfif>
<!--- Redirect --->
<cflocation url="">
</cfif>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]