Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a virtual host setup in apache, that works for SSL only. It is setup as so:

<IfModule mod_ssl.c>
        SSLCertificateFile /home/me/server.crt
        SSLCertificateKeyFile /home/me/server.pem
        SSLEngine on
        SSLOptions StrictRequire
        SSLProtocol all -SSLv2

DocumentRoot /me
<Location />
AllowOverride none
RemoveHandler .cgi .pl .py .php4 .pcgi4 .php3 .phtml .pcgi .php5 .pcgi5
RemoveType .cgi .pl .py .php4 .pcgi4 .php3 .phtml .pcgi .php5 .pcgi5

What I want to do, is have it so when someone goes to my site, they are automatically redirected to the https version.

Outside of the VirtualHost, I tried listening on port 80, and redirecting to the secure version, like so

Listen NameVirtualHost

Redirect permanent /

However, this apparantly caused an infinite loop.

What is the correct way to redirect to a https version of a site when the https site is a VirtualHost?

share|improve this question
Place the redirect inside a VirtualHost not 443 – Dan Feb 5 '15 at 19:10
up vote 1 down vote accepted

This is what I did:

Specify a port 80 virtual host and such as though you would be running a normal non-encrypted site. In that virtual host's root directory, put nothing but a single .htaccess file containing this:

Redirect 301 / https://your-ssl-site.tld

Seems to be work good enough for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.