What exactly does the variable SERVER_PROTOCOL actually contain (Apache 2.4)?

Binarus asked:

I have a website served by Apache 2.4 which should serve all contents via HTTPS. I already have appropriate redirections in place which work correctly, but don’t catch any pathological case. I wanted to improve that situation, and when doing my homework, came across the following example in this document:

<If "%{SERVER_PROTOCOL} != 'HTTPS'">
    Redirect "/admin/" "https://www.example.com/admin/"
</If>

I slightly modified this to reflect my situation:

<If "%{SERVER_PROTOCOL} != 'HTTPS'">
    Redirect "/" "https://www.example.com/"
</If>

Now, when trying to view any URL from my site, the browser goes into an infinite redirection loop.

I am suspecting that the example actually is wrong. SERVER_PROTOCOL does not seem to contain the value HTTPS under any circumstances. Instead, according to what I have read in other articles, it contains things like HTTP/1.1 (as the name would let expect).

So my question is: What exactly does SERVER_PROTOCOL contain under what circumstances / in what context? And what could be the reason that Apache’s official documentation website is the only one I have found during several hours of research that lists HTTPS as a possible value of SERVER_PROTOCOL?

My answer:


Congratulations, you found an error in the Apache documentation. Consider reporting it.

As for your immediate problem, you appear to be looking for REQUEST_SCHEME, which will contain

The scheme part of the request’s URI

for instance, http or https.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.