Apache: https to https redirect
Posted
by
Klaas van Schelven
on Super User
See other posts from Super User
or by Klaas van Schelven
Published on 2011-11-17T16:51:53Z
Indexed on
2011/11/17
17:56 UTC
Read the original article
Hit count: 748
apache
I'm trying to get Apache to redirect all http and https traffic to a single endpoint www.example.org. The http part is easy:
<VirtualHost *:80>
ServerName example.org
Redirect permanent / https://www.example.org/
</VirtualHost>
# long list of other domains, all redirecting to https://www.example.org/
<VirtualHost *:80>
ServerName www.example.org
Redirect permanent / https://www.example.org/
</VirtualHost>
I'm trying to do something similar for the https. It is my understanding that I need to specify one specific IP address, because the Host directive is also sent encrypted. So the below works:
<VirtualHost xx.xx.xx.xx:443>
ServerName www.example.org
# actual stuff happening here
</VirtualHost>
However, when I start adding the redirects to the config, like so:
<VirtualHost xx.x.xx.xx:443>
ServerName example.org
Redirect permanent / https://www.example.org/
</VirtualHost>
# long list of other domains
stuff breaks.
$ apache2ctl configtest
[warn] VirtualHost xx.xx.xx.xx:443 overlaps with VirtualHost xx.xx.xx.xx:443, the first has precedence, perhaps you need a NameVirtualHost directive
If I add a directive like so:
NameVirtualHost xx.xx.xx.xx:443
Connecting to the (ssl part of the) server starts to fail.
How do I solve this?
© Super User or respective owner