https (ssl) redirect code in php

by rajesh 2010-01-01 16:13:15

here is the code to be used in your page to redirect all http pages to https (secure connection - ssl)

<?
if($_SERVER['HTTPS']!="on")
{
$redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header("Location:$redirect");
}

echo "testing https (ssl) redirection using php";
?>

Tagged in:

1184
like
0
dislike
0
mail
flag

You must LOGIN to add comments