How to force HTTPS using htaccess

Force HTTPS using htaccess

This is a quick step-by-step walkthrough for forcing your site to load via HTTPS, instead of HTTP.

We recommend all websites relying on SSL encryption take these steps to guarantee your website traffic is using an encrypted connection.

  • Firstly, you need to locate your .htaccess file using your preferred FTP client. This will be in your httpdocs, public_html, www folder.Be aware that .htaccess files are classed as ‘hidden’ files, so you may need to make sure hidden files are visible via your FTP client’s settings.When you have found the .htaccess file, you’ll need to download it to your local machine and open it in your favourite code editor.

    find htaccess file in hosting
  • To force all traffic on your domain to use HTTPS, simply add the following. If you have existing code in your .htaccess file, you should add this above your current rewrite rules.

    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • Once you have updated your .htaccess file, you need to upload it back into your same folder.

    Please note: We strongly recommend making a backup copy of your existing .htaccess file before overwriting it.

Leave a Reply

Your email address will not be published. Required fields are marked *