I have certain pages on my website that have SSL enabled and others that don't need it. I used PHP to check what page the user is on and to see if it needs SSL or not. Here is the function: PHP Code: function redirectToHTTPS() { $url = substr($_SERVER['REQUEST_URI'],1); $https = array("page1.php","page2.php","etc..."); if(in_array($url,$https) && $_SERVER['HTTPS']!="on") { $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header("Location:$redirect"); } elseif(!in_array($url,$https) && $_SERVER['HTTPS']=="on") { $redirect= "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header("Location:$redirect"); } } The problem I am having here is with form processing. If a user processes a form (ie submits data), it submits, then redirects and outputs the wrong message and it gets confusing. Is there a way to do this other than a redirect or maybe though htaccess? Thanks in advance! Todd88 is offline Reply With Quote
function redirectToHTTPS() { $url = substr($_SERVER['REQUEST_URI'],1); $https = array("page1.php","page2.php","etc..."); if(in_array($url,$https) && $_SERVER['HTTPS']!="on") { $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header("Location: $redirect"); }elseif(!in_array($url,$https) && $_SERVER['HTTPS']=="on") { $redirect= "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header("Location: $redirect"); } } PHP: just added spaces between the Location: $var