What is an SSL and why do you need it?
SSL, or Secure Sockets Layer, is a vital security protocol establishing an encrypted link between a web server and a browser. Companies use SSL certificates on their websites to secure online transactions, safeguard customer information, and enhance overall security. By installing an SSL certificate, your website becomes accessible over both HTTP and HTTPS, with the latter being the preferred choice for data encryption and enhanced security.
Forcing HTTPS on All Traffic:
-
Navigate to File Manager in your hosting panel and locate or create .htaccess inside the public_html folder.
-
Scroll down to find
RewriteEngine On
and insert the following lines of code below it:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
- Save the changes.
Forcing HTTPS on a Specific Domain:
If you want to redirect only a specific domain to its HTTPS version, use the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain1.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Make sure to replace yourdomain1
with the actual domain.
Forcing HTTPS on a Specific Folder:
To enforce HTTPS on specific folders, place the .htaccess file in the folder. Use the following code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Change the folder references to the actual directory names.
After implementing these changes, clear your browser's cache and attempt to connect to your site via HTTP. Correctly configured, the browser will automatically redirect you to the secure HTTPS version. Secure your website with SSL for improved data protection and overall website security.