This article will teach you how to redirect HTTP to HTTPS using the .htaccess file.
Use FTP or the File Manager in your hosting control panel to navigate to your website’s root directory (usually public_html).
.htaccess FileIf you already have a .htaccess file, open it for editing. If there’s no .htaccess file, create one by selecting “New File” and naming it .htaccess.
Insert the following code at the top of your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code checks if the request is not secure (HTTP) and redirects it to HTTPS (SSL-enabled version of your site).
After adding the code, save the .htaccess file and upload it back to the server if necessary.
http://yourdomain.com) and check that it automatically redirects to the HTTPS version (https://yourdomain.com).By following these steps, you can ensure that all visitors to your website are automatically directed to the secure HTTPS version.