I'm editing an .htaccess
file..
In RewriteCondition for RewriteRules, HTTPS_HOST
seems to only match urls that are accessed via https://
protocol (ssl). I saw in docs somewhere that it's a T/F variable that indicates if the url was accessed using the secure protocol.
However, I'm having trouble finding on the docs whether HTTP_HOST
only matches http://
protocols, or if it effectively matches //
relative protocols, meaning it matches both http://
and https://
.
Can someone confirm one way or the other, or point me to a definitive source for this info?
Also, if HTTP_HOST
matches both protocol variants, what is the best way to filter for matches of only http://
protocols ?
Example:
<IfModule mod_rewrite.c>
RewriteEngine on
Rewritecond %{HTTP_HOST} ^\/\.(?!some-url).*$
RewriteRule (.*) https://www.example.com/$1 [R=301,L,NC]
</IfModule>
In contrast:
...
Rewritecond %{HTTPS_HOST} ^\/\.(?!some-url).*$
...
Edit: Experimentation shows that HTTP_HOST
does seem to match both protocols, whereas HTTPS_HOST
only matches when the protocol, or url starts with https://
.
.
(Note re: apache2
tag
TBH, I am not certain what version of apache I am running. To try finding out, so I could attach the proper tag..
I tried httpd -v
, apache -v
, apache2ctl -S
, apachectl -S
, httpd -S
, etc. (It's not a virtualhost question, and I have nginx, which is think is for that (virtual server) anyway, but I tried those last 3 (virtualhost) commands anyway to see if they would enlighten me on my apache version).
Responses to those commands say either that I must first install apache2, or it is an unknown command.
I have an /etc/apache2
folder, but not an /usr/local/apache
(hence no /usr/local/apache/bin/httpd
folder).
)