For this method to work, you either must have your hosting provider to enable build-in AutoSSL by cPanel or to purchase a valid HTTPS/SSL cert from SSL Cert Reseller.


The IT Guys is hosting provider and also an SSL cert Reseller. For more information, please email us at support@theitguys.my or initiate a chat with us.


If you have added an SSL certificate to your domain, you can force all visits to your site to use HTTPS to ensure your traffic is secure. This solution shows how to do this depending on where your site is hosted.


Forcing the domain to serve securely using HTTPS (for all website traffic)


The following forces any HTTP request to be rewritten using HTTPS. For example, the following code forces a request to http://example.com to load https://example.com. It also forces directly linked resources (images, css, etc.) to use https:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 

If this isn't working for you, first check your line endings. Copy/paste from your web browser into a text editor may not work right, so after pasting into your text editor you should delete each line break and add it back in (line break = return key).


The IT Guys provides services to edit your htaccess should you need any help.


NOTE: If you are editing for htaccess file which has CMS or Web Application, please consult with your web developer or please refer to their documentation before editing the above code. 
 
DISCLAIMER: The IT Guys is not responsible if you break your web application or CMS.