Mac OS X
How to redirect all HTTP requests to HTTPS
on Saturday, November 3, 2018
The old way to redirect all HTTP requests to HTTPS in the Apache configuration file...
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But this method is no longer recommended (see "When not to use mod_rewrite") and this is the new way...
<VirtualHost *.80>
ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost>
<VirtualHost *.443>
ServerName www.example.com
# SSL configuration goes here...
</VirtualHost>
|