Enforce protocol
Posted: Wed Apr 26, 2006 4:14 pm
feyd | Please use
Is there a way to use this code to enforce http on exit of the page?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello. I am currently using the following code to enforce https protocol:Code: Select all
<?php
function enforce_protocol($p){
if($p=="https"){
if($_SERVER['HTTPS']==""){
header("Location:https://".$_SERVER['HTTP_HOST'].":443".$_SERVER["PHP_SELF"].(($_SERVER["QUERY_STRING"]=="")?"":("?".$_SERVER["QUERY_STRING"])));
}
}
else if($p=="http"){
if($_SERVER['HTTPS']=="on"){
header("Location:http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"].(($_SERVER["QUERY_STRING"]=="")?"":("?".$_SERVER["QUERY_STRING"])));
}
}
}
enforce_protocol(https);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]