How to redirect HTTP to HTTPS (SSL) Using .htaccess files

Some website did not support automation of setup, such as the website is build by HTML only and no script used, so the user required to setup the SSL manually by redirecting the access from HTTP to HTTPS, this can be done by using the .htaccess inside the cPanel to capture all the request and redirect to HTTPS only. This article will show how to easily setup it. Note: Backup your website in case something goes wrong.

 

The setup begin with Login into your cPanel, then

  1. Open the File Manager inside the cPanel: Files > File Manager > Document Root for:
  2. Select the domain name you want to access
  3. Check “Show Hidden Files (dotfiles)”
  4. If you can't find the step 3, you can first enter the File Manager then go to Setting with the gear icon at the top left, to show the hidden files

 

 

  1. Look for the .htaccess file inside your public_html folder, if there is no .htaccess file then you can create new files witht the name, ".htaccess"
  2. Open/Edit the files then check if there any content on the files, if have content, then scroll to the bottom of the files, then add this code, 
  3. RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
  4. Please change "www.yourdomain.com" inside the code above with your domain name then click save, and now you can test your website should be access directly from HTTPS. 

 

If you having trouble to setup this, you may contact our team and we will help you to get it setup on your website. This setup is suitable for basic HTML website, while if you using website with the script such as WordPress you just need to go to the setting of the website then update from HTTP to HTTPS. 

 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Install an SSL Certificate inside cPanel

You don't need to spend extra money to get SSL certificate at SenangHost since it included inside...

Add New Domain to cPanel

Before adding new domain to your account you need to verify your hosting package is support more...