I'm having trouble with my apache config. Several sites are hosted on the server, each connected to a domain.
Here's an excerpt from the config:
<VirtualHost *:80>
ServerName [name].com
Redirect permanent / https://[name].com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.[name].ch
ServerAlias [name].ch
Redirect permanent / https://www.[name].ch/
</VirtualHost>
What's working:
- http requests to
[domain].com
and[domain].ch
are redirected to https - http to
www.[domain].com
is redirected tohttps://[domain].com
https://www.[name].ch
if requested directly (so presumably no issue with ssl config)
What's not working:
- http to
www.[domain].ch
is redirected tohttps://[domain].com
instead ofhttps://[domain].ch
Requests to www.[name].ch
are being returned with a 301
to https://[name].com
.
apache2ctl -S
lists all specified virtual hosts as expected.
Any hints as to what might be wrong with the config? I also had a look at this post (apache rewrite rules, non-www, https), which unfortunately didn't solve this problem.