[pmwiki-users] Detecting an SSL Connection
H. Fox
haganfox at users.sourceforge.net
Fri Aug 11 21:08:38 CDT 2006
On 8/11/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Fri, Aug 11, 2006 at 01:26:02PM +0100, Ian Barton wrote:
> > Some of my sites can be accessed via SSL or via http. I would like to
> > display a gif if the user is using SSL. So the question is "How can I
> > detect within PmWiki if the user is using https?"
>
> It depends on your webserver -- there's no perfect
> standard for it. However, the standard mechanism would
> be to do something like:
>
> $isHTTPS = isset($_SERVER['HTTPS']);
This may be better for some servers (that could possibly set that to
'off' or 'OFF')
$isHTTPS = (@strtolower($_SERVER["HTTPS"]) == 'on');
or possibly as a last resort
$isHTTPS = ($_SERVER['SERVER_PORT'] == '443');
I'm using this to enforce an SSL-only wiki:
if (!@strtolower($_SERVER["HTTPS"]) == 'on'){
header("Location: https://www.example.com/wiki/");
exit('<html><body>
<a href="https://www.example.com/wiki/">Please use SSL.</a>
</body></html>');
}
Hagan
More information about the pmwiki-users
mailing list