Effortlessly enforce the redirection of HTTP to HTTPS by configuring your .htaccess file in cPanel. Follow these sequential steps to ensure a smooth transition:

  • Begin by accessing your cPanel account. Navigate to the File Manager and locate the .htaccess file within the root directory of your website. Discover the .htaccess file from the settings and verify the “Show hidden files”
Redirect HTTP to HTTPS
  • Open the .htaccess file using the text editor, and carefully insert the following code snippet:
How to Redirect HTTP to HTTPS from .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

This code instructs the server to redirect any HTTP requests to the secure HTTPS protocol.

  • Save the changes made to the .htaccess file and exit the text editor.

By following these steps, you seamlessly enhance the security of your website by ensuring that all HTTP traffic is automatically redirected to the encrypted HTTPS counterpart.