Is there an easy way to perform an automatic redirect when a user attempts to reach the site on a non-SSL port? 80 --> 443. I am running a stand-alone server. Not sure if this should be done in a Session Open event or in the App HandleURL event.
Thanks! Appreciate the response. One follow-up question: I want to do the redirect in HandleURL but I’m not quite sure when do it? I’ve tried redirecting every request that comes in insecure like this with no luck:
// Request came in unsecure. Automtically redirect to secure URL
if ( NOT Request.Secure ) then
Request.Status = 304
Request.Header(“LOCATION”) = “https://” + app.HostName
return(TRUE)
end if
App.HostName is a property where I store the site name.
Here ya go. Just replace the newURL string with the one that the app should be redirected to for SSL.
Function HandleURL(Request As WebRequest) Handles HandleURL as Boolean
if request.path = "" then
if not request.Secure then
dim newURL as string = "https://your.domain.com"
request.Header("Location") = newURL
request.Status = 301
return True
end if
end if
End Function