1

Suppose, I have two website first.com and second.com. I am making a curl request from first.com by the curl. Is it, possible to know that it,s https request or http request on server second.com?

D Singh
  • 283
  • 3
  • 13
  • possible duplicate of [How To Find Out If You are Using HTTPS Without $\_SERVER\['HTTPS'\]](http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps) – secelite Feb 02 '15 at 10:26
  • If i user $_SERVER variable, it,s show the status current server second.com. But i want to know the status of first.com while a curl request coming from first.com and hit second.com. I want know that, Is request coming from secure server at second.com – D Singh Feb 02 '15 at 10:34
  • As i posted in my answer, the $_SERVER["HTTPS"] shows whether the server who send the request was using HTTPS. – MadsBjaerge Feb 02 '15 at 10:36

3 Answers3

1

Check for $_SERVER["SERVER_PORT"] if its 80, then its a simple request, if 443 or secure protocol's port then its https.

And maybe UseCanonicalPhysicalPort = On has to set on Apache2.

http://php.net/manual/en/reserved.variables.server.php

Tamás Szabó
  • 348
  • 2
  • 10
1

From the manual, it seems that $_SERVER contains an indication whether this is HTTP or not.

PHP Manual

'HTTPS' Set to a non-empty value if the script was queried through the HTTPS protocol. Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.

So checking $_SERVER["HTTPS"] should be okay, i dont have any idea whether this can be trusted or not.

MadsBjaerge
  • 116
  • 5
  • I want to know the status, when request coming on server second.com, it,s coming from secure server or not – D Singh Feb 02 '15 at 10:38
  • "'HTTPS' Set to a non-empty value if the script was queried through the HTTPS protocol", so if the request is from a server running HTTPS, it the value would be set to a non-empty value. – MadsBjaerge Feb 02 '15 at 12:33
0

Chauhan,

it's possible via PHP Global variable. you have uses $_SERVER['HTTP_REFERER'] variable in second.com. it will return http request url.

Learn more for php global variable visit http://php.net/manual/en/reserved.variables.server.php

mithun raval
  • 180
  • 3