Apr 03

Apache HTTP to HTTPS redirect using mod_rewrite

By agatewood Web Comments Off on Apache HTTP to HTTPS redirect using mod_rewrite

On Apache, to redirect everything that comes in to port 80 to port 443, insert the following into the Apache config file (usually /etc/httpd/conf/httpd.conf). This should be added between the or tags for the site you wish to alter.

Modify /etc/httpd/conf/httpd.conf :

RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

Then restart Apache. That’s it. All traffic should now be redirected to use SSL.

Tagged with:
preload preload preload