I have virtual host on Apache that has configurations similar to the following:
<VirtualHost *:80>
DocumentRoot "/home/doe/www/factory/public"
<Directory "/home/doe/www/factory/public">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
ServerName doe.example.com
ServerAlias qa.dev
ServerAlias doe202.ddns.net
ErrorLog "/home/doe/logs/doe.log"
CustomLog "/home/doe/logs/aq-access.log" common
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/home/doe/www/factory/public"
<Directory "/home/doe/www/factory/public">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
ServerName doe.example.com
ServerAlias qa.dev
ServerAlias doe202.dddns.net
ErrorLog "/home/doe/logs/doe.log"
CustomLog "/home/doe/logs/aq-access.log" common
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/doe.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/doe.exmple.com/privkey.pem
</VirtualHost>
What I need to achieve is to redirect only http://doe.example.com
to https://doe.example.com
of course with any URI attached to it.
I have tried to look for this answer of that question: http to https apache redirection, but it will redirect all hosts to HTTPS.
I also tried to change serverName
directive in port 80 virtual host, but this will prevent users that use http
from access at all.