Some context: I'm serving a website under the domains domain.com
and alternate-domain.com
. I would like to redirect all requests so that they:
domain.com
(e.g. remove the www
prefix)That's what I have at the top of my apache configuration:
<VirtualHost *:80>
Redirect permanent / https://domain.com/
</VirtualHost>
<VirtualHost *:433>
Redirect permanent / https://domain.com/
SSLEngine on
# SSL Certificate directives are here.
</VirtualHost>
And then later on I have the config for https://domain.com:
<VirtualHost *:443>
ServerName domain.com
# ...
</VirtualHost>
This works as expected when I access non-HTTPS pages:
https://domain.com
https://domain.com
However, it doesn't work when I access domains through HTTPS. What I mean by that is that the redirection doesn't happen.
Examples:
(Note: it's normal that certificate warnings occur as they don't match the domain for which I have the certificate. All the more reason for redirecting users.)
What am I doing wrong?
Ok, problem solved - I made a typical stupid mistake.
In the SSL default vhost, I listen on port 433
. Should be 443
of course.