Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Create or locate your .htaccess file: This file is a plain text file that contains configuration settings for Apache web server. It is usually located in the root directory of your website.

  2. Open your .htaccess file: You can use any text editor to open the file. If you are using Linux or Mac, you can use a command-line editor like vi or nano.

  3. Add the following code to the top of the .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code uses the mod_rewrite module to redirect all HTTP requests to HTTPS.

  1. Save the changes and upload the .htaccess file to your server.

  2. Test the redirection: Open your website using HTTP and check if it redirects to HTTPS. You can also use a redirect checker tool to confirm the redirection.

Note: Before making changes to your .htaccess file, it is recommended to create a backup copy of the original file in case anything goes wrong.