Jump to content

HTTPS


caster001

Recommended Posts

Hello,

Just wondering, I've used the methods people have told me to get the page address a current might be on using php but so far it mainly consists of the link after 'http://" so my question is, is there a way in php to automatically initialize the page in a HTTPS address?

Thanks.
Link to comment
Share on other sites

I'm not sure that I fully understand your question, but these variables may help to tell if you are in an HTTPS request:

[code=php:0]$_SERVER['SCRIPT_URI']
$_SERVER['SERVER_PROTOCOL']
$_SERVER['SERVER_PORT'] # Usually 80 for HTTP, 443, for HTTPS[/code]


These may not always be set..
Link to comment
Share on other sites

alright well you could do something like this:

[code=php:0]
if(substr($_SERVER['REQUEST_URI'], 0, 5) == 'https'){
echo "You are coming from HTTPS!";
}else{
echo "Why arnt you in secure?!";
}
[/code]

or you could make a function

[code=php:0]
function ishttps(){
if(substr($_SERVER['HTTP_REFERER'], 0, 5) == 'https'){
return true;
}else{
return false;
}
}

if(ishttps()){
echo "in https";
}else{
echo "not https!";
}
[/code]

pretty pointless though, unless your going to be calling it a fair bit. hope its what you are looking for.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.