Re: checking for and enforcing https

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-02-26 at 11:00 -0500, Dan Joseph wrote:
> On Tue, Feb 26, 2008 at 10:56 AM, tedd <tedd.sperling@xxxxxxxxx> wrote:
> 
> >
> > So, let's say I wanted script "secure.php" to be forced to use https
> > -- do I use something like what Dan provided, namely?
> >
> > <?
> >     if($_SERVER['SERVER_PORT'] != '443') {
> >         $url = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] :
> > $_SERVER['SERVER_NAME'];
> >         header("Location:
> > https://".$url.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
> >         exit;
> >     }
> > ?>
> >
> > I know I could test the code for myself, but this is quicker.
> >
> >
> 
> Yep.  Use that or: if ($_ENV["HTTPS"] == "off").  Daniel's code is port
> specific, this one checks for HTTPS being on or off.

Surely you mean $_SERVER['HTTPS'] and not $_ENV['HTTPS'].

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux