Re: checking for and enforcing https

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

 



---- Stephen Johnson <maillists@xxxxxxxxxxxxxxxx> wrote: 
> > Or you can cheat...
> > 
> >  $url = $_SERVER['SERVER_NAME'];
> >  header( 'Location:https://'.$url.'');
> > 
> > 
> 
> I think that would cause an infinite loop of redirection...
> 
> This would be better
> 
> <?php
> 
> $curPort = $_SERVER['SERVER_PORT'];
> $pageTo = $_SERVER['REQUEST_URI'];
> 
> if($curPort == "80") {
>            // go secure
>            header("location:https://www.domain.com$pageTo";);
>            exit;
> }
> ?> 
> 
> 
Also realize, your code ONLY works if people use the standard ports...

With the way I have it check ($SERVER variables), then you eliminate that and no matter what ports the server runs on, you get the correct switching you need.

Wolf

-- 
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