PDA

View Full Version : Redirecting to non HTTPS protocol in IE



GoDawgs
25 May 2011, 08:22 PM
Hi, I have a page that goes on a loop when I try to use the following functions in Internet Explorer:



function redirectToHTTPS(){
if($_SERVER['HTTPS']!="on"){
if($_SERVER['HTTP_HOST'] == "www.peeka.com"){
$redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}else{
$redirect= "https://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
header("Location:$redirect");
}
}

function redirectToNonHTTPS(){
if($_SERVER['HTTPS']=="on"){
if($_SERVER['HTTP_HOST'] == "www.peeka.com"){
$redirect= "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}else{
$redirect= "http://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
}elseif($_SERVER['HTTP_HOST'] == "peeka.com"){
$redirect= "http://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
header("Location:$redirect");
}


How do I get around this? Thanks.

is_numeric
26 May 2011, 05:01 AM
I wouldn't do it using PHP

Do it in your .htaccess file



RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [NC,R,L]

Try here for more options....

http://bit.ly/nwfQr