I configured an Apache server on my Ubuntu 18.04 computer with HTTPS support.
I have a SSL Certificate for *.example.com so my solution for have HTTPS on example.com was to redirect it to www and then redirect to HTTPS for all the subdomains.
Here is my HTTP version redirection config:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^/?(.*) http://www.%{SERVER_NAME}/$1 [R,L]
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
I have tried replacing the %{SERVER_NAME}
with %{HTTP_HOST}
I also restarted apache2 many times and tried clearing the cache of my browsers but it keeps redirecting to https://www.
P.S. I am not an Apache expert so please tell me if I am using the syntax wrong