ServerAlias
directives to get Apache to recognize other subdomains or domains mapped to the same document root.
You should have a separate virtual host configuration for each port to listen on. This is so the domain request goes to the right document root regardless of which port is used. This however will not change the requested protocol. To do that use a rewrite directive in .htaccess. There are a number of possible directives, this one is pretty common:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]
Naturally you would change example.com
to the proper domain name. Whether you use www
or not is up to you, assuming you have the virtual host server names squared away.
I had to add these lines BEFORE the module for <VirtualHost *:443>
<VirtualHost *:80>
ServerName summit-estates.com
RedirectPermanent / https://www.summit-estates.com/
</VirtualHost>
This caught the random “what if” traffic coming in on Port 80 and made sure it gets tossed to the correct port WITH the correct virtual host. Problem solved by band aid! When in doubt, fix in production; that’s what I always say.
]]>RedirectPermanent
, thanks! ??
]]>