Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

My website has an SSL cert (example url: Under Apache it's set up for both port 80 and port 443. So under the following configuration, anyone who goes to is sent to . But for visits from Internet Explorer, the redirect doesn't happen. Instead, http visits get a "Internet Explorer cannot display the web page." with a list of client-side solutions to try.

Any ideas on how to fix the config so IE visits have the same behavior as the other browsers (that is, send http to https automatically)?

NameVirtualHost *:443

<VirtualHost *:80>
  DocumentRoot /var/www/somewebroot

<VirtualHost *:443>
     DocumentRoot /var/www/somewebroot

*Tested IE8, IE9 beta

share|improve this question
up vote 1 down vote accepted

Placing this code in the HTTP virtual host's definition should do it.

RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^/(.*) [R=301,L]

If you are testing changes you may have problems with IE unless you shut down all IE windows and restart. IE can be use its cache aggressively.

EDIT: You need to ensure mod_rewrite is enabled. Command is a2enmod rewrite. It will tell you if the module is already enabled. If not you will need to shutdown and restart the server after enabling the module.

Add the lines above to your virtual host definition and use apache2ctl graceful to reload the modified configuration. The Apache documentation has details on rewriting.

You should see the redirect as a 301 status request in your access log followed by a 200 or 304 status on the HTTPS connection. The displayed URL should change to the new location.

Logging the port in an extend log format helps to see which connection things are happening on. Alternatively, use separate logs for each virtual server.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.