Redirect all HTTP traffic to HTTPS

There are lots of “plugins” and “applications” being sold to people these days which perform this step but they are not necessary. All you need is an .htaccess file if you’re using Apache or one of it’s variants, or a few lines of code in your Nginx configuration if you’re using the Nginx webserver, and you’ll be good to go.

Apache

Just place this in your .htaccess file

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Nginx

Here is a block of code that goes into your per-server configuration for Nginx

server {
listen 80;
server_name example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}

That’s it! If you have any questions please send us an E-mail and we’ll be happy to help you!

If you found this helpful, please share!
Tags: , ,

Comments are closed here.