caster001 Posted November 29, 2006 Share Posted November 29, 2006 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 https://forums.phpfreaks.com/topic/28826-https/ Share on other sites More sharing options...
btherl Posted November 29, 2006 Share Posted November 29, 2006 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 https://forums.phpfreaks.com/topic/28826-https/#findComment-131969 Share on other sites More sharing options...
caster001 Posted November 29, 2006 Author Share Posted November 29, 2006 I actually never thought of checking the ports, well I just want to check if the page is hitting the HTTPS address for security reasons, I need to make it a manditory requirement though, so what do you mean by "these may not always be set" ? Link to comment https://forums.phpfreaks.com/topic/28826-https/#findComment-131977 Share on other sites More sharing options...
JasonLewis Posted November 29, 2006 Share Posted November 29, 2006 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 https://forums.phpfreaks.com/topic/28826-https/#findComment-132012 Share on other sites More sharing options...
caster001 Posted November 29, 2006 Author Share Posted November 29, 2006 Actually all of them really helped.Thanks a lot guys. Link to comment https://forums.phpfreaks.com/topic/28826-https/#findComment-132097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.