Redirect HTTP to HTTPS Using .htaccess File: Step by Step

Redirect HTTP to HTTPS Using .htaccess File: Step by Step

By: SolutionsHint    27 views Updated: 08th Sep, 2018
Redirect HTTP to HTTPS Using .htaccess

Website security is really important now a days, becacuse attacker always try to hack website and may harm your website content and files, so we should keep secure, so whenever we migrate our website from HTTP to HTTPS we need to redirect our domain from to and also wit http://www. to http://www.

Editing .htaccess File

There are instructions for the .htaccess file that tell the server how to action takes place  and directly affects on website functions. Common directives in .htaccess file anything miss match your website will stop working:

  • Redirects
  • Rewriting URLs

Ways to edit an .htaccess file:

  1. Edit the file on your computer and upload it to the server using FTP.
  2. Use “Edit” mode in FTP program that allows you to edit a file remotely.
  3. Use a text editor and SSH to edit the file.
  4. Use the File Manager in cPanel to edit the file.

Editing .htaccess in cPanel File Manager

Note: Always first take a Backup your website in case something goes wrong.

  1. Login to cPanel
  2. Files > File Manager > Document Root for:
  3. Now select the domain name you want to access
  4. Check “Show Hidden Files (dotfiles)”htaccess files are by default hidden in cPanel
  5. Click “Go”
  6. After a new tab or window opens, look for the .htaccess file.
  7. Right click on the .htaccess file and click on “Code Edit” on the menu.
  8. A dialogue box may pop up asking about encoding. Click “Edit” button to continue.
  9. Edit the file
  10. “Save Changes” when done.
  11. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  12. Once you are done, click “Close” to close the window.

1. How to Redirecting HTTP to HTTPS

Redirect All Web Traffic, along will your all website pages

If you have already existing code in  .htaccess, the just add bellow the end of file and save it.

2. How to Redirect Only for  Specific Domain

3. How to Redirect Only for  Specific Folder

Note: Don’t forgot to change or replace your actual domain name with this code, in this code i use www.yourdomain which is only for understanding!! anything else let us know in comment section!

About the Author

I am a professional blogger from my heart, I am going through all the possible ways that can help to audience. I am trying my best to write content that my readers will like me. I will really be happy when my readers will become more happy with my blog.

Leave a Reply

Your email address will not be published. Required fields are marked *