26Apr, 2018

How to Force HTTPS Using the .htaccess


SSL is very necessary to ensure your website’s visitor to an encrypted connection. It’s important for security, accessibility, or PCI compliance reasons. If you want to learn more about the SSL/HTTPS then visit this article HTTP Secure (HTTPS).

Nisar Soft is offering free SSL with the web hosting package. This SSL is automatically installed within 24 to 72 hours after activating your web hosting.


Forcing HTTPS with .htaccess


To force all traffic to use HTTPS, insert the following lines of code in the .htaccess file in your website’s root folder.


RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

NOTE: If you have existing code in your .htacess, add this above where there are already rules with a similar starting prefix.

If you have any question, comment below. If you want to connect with Nisar Soft support team, start a chat or open a ticket.


Leave a Reply

Copyright © 2019 Nisar Soft. All rights reserved.