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.
Table of Contents[Hide][Show]
Requirements:
- SSL certificate
- Web server
- Basic coding skills
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 ^(.*)$ https://methodshop.com/$1 [R,L] # END
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.
Frank Wilson is a retired teacher with over 30 years of combined experience in the education, small business technology, and real estate business. He now blogs as a hobby and spends most days tinkering with old computers. Wilson is passionate about tech, enjoys fishing, and loves drinking beer.
Leave a Reply
You must be logged in to post a comment.