Home » .htaccess » How To Use .htaccess To Force SSL On Your Website

How To Use .htaccess To Force SSL On Your Website

Using .htaccess we can do many things one of that is force your website to use an SSL (HTTP) to (HTTPS) connection, which encrypts and passes the information between a web server and the web browser.

Create and Edit .htaccess files.

Before using .htaccess we want to know about the .htaccess because even small mistakes, such as spelling mistakes or typos, in .htaccess files it makes big problem with viewing the website, In this case, before editing the .htaccess file we need to keep a backup file for .htaccess.

Once you Log in to your web server cPanel click File Manager. Then click upper right side corner settings and make sure show hidden files in selected and click save the file.

For more information about showing .htaccess hidden files, Click Here.

Once you see the file directory create or edit the .htaccess file. If you can’t see the .htaccess file create a new file, click the new file and name the file .htaccess. If you need to edit an existing .htaccess file select the file and click edit.

To force SSL for the entire website add the following code in your .htaccess file. For subdirectory, We need to create a .htaccess file in the subdirectory and add the code to force SSL.

Then click to save and close the file. Open your website in your web browser to test the change.

Was this article helpful?

Yes No

How can we improve it?


We appreciate your helpul feedback!

Your answer will be used to improve our content. The more feedback you give us, the better our pages can be.

Follow us on social media:

Facebook Pinterest


Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts.

Leave a Reply

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

Back to top