ASP
<%
if Request.ServerVariables("HTTPS") = "off" Then
	Response.Redirect("https://" & 
Request.ServerVariables("HTTP_HOST") &
	Request.ServerVariables("URL"))
End if
%>

PHP
if ($_SERVER['SERVER_PORT']!=443)
{
	$url = "https://". $_SERVER['SERVER_NAME'] . 
":443".$_SERVER['REQUEST_URI'];
	header("Location: $url");
}

Coldfusion
<CFIF #CGI.SERVER_PORT# EQ 80>
        <CFLOCATION URL="https://www.domainname.com">
</CFIF>