Forwarding 80 to 443 on Nagios woes

Solution 1:

Here's my redirecting non-ssl VirtualHost in its entirety:

<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName www.example.com
  ServerAlias example.com

  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

  LogLevel warn    
  CustomLog /var/log/apache2/access.log vhost_combined
  ErrorLog /var/log/apache2/error.log
</VirtualHost>

This belongs in the Apache config rather than in .htaccess.

The main difference is in our RewriteCond lines, where yours is %{SERVER_PORT} 80 and mine is %{HTTPS} !=on.

Solution 2:

It's much easier to do the following if you have two different vhost entries setup.

Redirect permanent / https://our.server.org/

In the non-ssl vhost. Don't worry that will cover all uris entered.