You have a website and an SSL-encrypted connection. You want the advantages https affords for SEO, security, and PCI compliance. But how do you force all web traffic to your site to be always HTTPS? This simple edit to your .htaccess file will make all http requests to your website automatically to switch to https.


Access Your Web Server

There are several ways that you can log in to your web server and edit its files. An FTP client or cPanel will both do the trick.

Locate Your htaccess File

The htaccess file contains special directions for your server to execute at the server level. Things like redirects and caching rules can all be specified in the htaccess file.

Edit Your htaccess File

You can force your website to use https by adding the following code to your htaccess file.

# Force HTTPS
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]

If you already have existing code in your .htaccess file, then make sure you add these code to the section that already contains the “rewrite” rules. Also, make sure you only have “RewriteEngine On” once in your htacess file. Delete that line from the code below if you have a duplicate.