How to redirect HTTP to HTTPS Using .htaccess

Nowadays most of all web browsers have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility, or PCI compliance reasons is important. It becomes necessary to redirect from HTTP to HTTPS.

I will guide you step by step how to redirect from HTTP to HTTPS using .htaccess

  1. First, log in to cPanel
  2. Then navigate File Manager > public_html
  3. Now select the domain name you want to access (If having multiple hosting domains or using subdomain)
  4. Check there .htaccess file exist if not then click on setting icon showing on the right top corner and then Check “Show Hidden Files (dotfiles)”
  5. Click “Go”
  6. Right-click on the .htaccess file and click on “Code Edit” on the menu.
  7. A dialogue box may pop up asking about encoding. Click the “Edit” button to continue.
  8. Edit the file
  9. “Save Changes” when done.
  10. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  11. Once you are done, click “Close” to close the window.

Add Code in .htaccess file

Add the below code either top of your htaccess file or bottom, after saving check your site working fine.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

 


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420