Page 1 of 1

forwarding all http to https

Posted: Tue Jul 18, 2006 10:34 am
by Luke
This is kind of a stupid question, because I know how to do it I think, but how would you forward all traffic from http to https? (is there a better way than strpos?)

Posted: Tue Jul 18, 2006 10:35 am
by feyd
strpos()? $_SERVER['HTTPS'] ;)

Posted: Tue Jul 18, 2006 11:08 am
by Luke
so I want to make sure that the user is going to https://www.silversteepsecure.com (hot http://silversteepsecure.com or https://silversteepsecure.com or http://silversteepsecure.com). So would this be correct?

Code: Select all

if(empty($_SERVER['HTTPS']) || strpos(strtolower($_SERVER['HTTP_HOST']), "www") === false)
header('Location: https://www.silversteepsecure.com' . $_SERVER['REQUEST_URI']);

Posted: Tue Jul 18, 2006 2:46 pm
by John Cartwright
The Ninja Space Goat wrote:so I want to make sure that the user is going to https://www.silversteepsecure.com (hot http://silversteepsecure.com or https://silversteepsecure.com or http://silversteepsecure.com). So would this be correct?

Code: Select all

if(empty($_SERVER['HTTPS']) || strpos(strtolower($_SERVER['HTTP_HOST']), "www") === false)
header('Location: https://www.silversteepsecure.com' . $_SERVER['REQUEST_URI']);
try it yet?

Posted: Tue Jul 18, 2006 2:48 pm
by Luke
It works. No issues that I have found...