detecting ssl

From: Date: Wed, 13 Oct 2004 11:46:20 +0000
Subject: detecting ssl
Groups: php.general 
Request: Send a blank email to php-general+get-199356@lists.php.net to get a copy of this message
Hi there, I am trying to detect ssl with the SERVER variable from PHP. Backgrond is that a user might be on an ssl page and the next navigation link he clicks might simply be a non ssl site, but due to relative links there is no way to create a non ssl url for that. My trie was to check the communication port and if the site should not be ssl, tut the url is a https one, a redirect via php should take place. Here is the code: if ($_SERVER[SERVER_PORT] == '443' AND !$SSL){ header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); exit; } It worked for me, for thousands of others, but not for everybody. Some people just could not use the site anymore. So I guess the SERVER_PORT var can not necessarily be count on. Has anybody an idea how to overcome this? Thanx for any hint, Merlin

« previous php.general (#199356) next »