From: "Ben Miller" on
Is there a PHP function that will return whether the request was http or
https? I have functions that need to cURL other servers - sometimes over
SSL, sometimes not, depending whether the function is called from
http://www.mydomain.com/script_that_calls_function.php or
https://www.mydomain.com/script_that_calls_function.php



Hope the question is clear. Thanks,



Ben





From: Jonathan Tapicer on
Hi,

isset($_SERVER['HTTPS']) should do it.

Regards,

Jonathan

On Sat, Jan 23, 2010 at 2:11 PM, Ben Miller <biprellim(a)gmail.com> wrote:
> Is there a PHP function that will return whether the request was http or
> https?  I have functions that need to cURL other servers - sometimes over
> SSL, sometimes not, depending whether the function is called from
> http://www.mydomain.com/script_that_calls_function.php or
> https://www.mydomain.com/script_that_calls_function.php
>
>
>
> Hope the question is clear.  Thanks,
>
>
>
> Ben
>
>
>
>
>
>
From: Nathan Rixham on
Ben Miller wrote:
> Is there a PHP function that will return whether the request was http or
> https? I have functions that need to cURL other servers - sometimes over
> SSL, sometimes not, depending whether the function is called from
> http://www.mydomain.com/script_that_calls_function.php or
> https://www.mydomain.com/script_that_calls_function.php
>
> Hope the question is clear. Thanks,
>

$_SERVER['HTTPS']
Set to a non-empty value if the script was queried through the HTTPS
protocol.

From: Adam Richardson on
Just as a warning, I have worked on linux servers where this did not work,
perhaps because of what silverquick points out:
http://www.php.net/manual/en/reserved.variables.server.php

I think the HTTPS element will only be present under Apache 2.x. It's not in
> the list of "special" variables here:
> http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond

But it is here:

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond


Again, not sure that was the issue, but I know there have been some linux
servers that didn't provide this information, so make sure you test it out
well.

Adam

On Sat, Jan 23, 2010 at 12:44 PM, Nathan Rixham <nrixham(a)gmail.com> wrote:

> Ben Miller wrote:
> > Is there a PHP function that will return whether the request was http or
> > https? I have functions that need to cURL other servers - sometimes over
> > SSL, sometimes not, depending whether the function is called from
> > http://www.mydomain.com/script_that_calls_function.php or
> > https://www.mydomain.com/script_that_calls_function.php
> >
> > Hope the question is clear. Thanks,
> >
>
> $_SERVER['HTTPS']
> Set to a non-empty value if the script was queried through the HTTPS
> protocol.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com