How to redirect HTTP traffic to HTTPS

How to Redirect HTTP Traffic to HTTPS Using .htaccess

Securing your website with HTTPS is not only good for security but also for SEO. You can easily redirect all HTTP traffic to HTTPS by adding a few lines of code to your .htaccess file. Here's how:

  1. Access the File Manager: Log into your hosting control panel and navigate to the File Manager. Make sure you're in the public_html directory, where your website files are stored.
  2. Locate or Create .htaccess: Look for the .htaccess file in the public_html folder. If it's not visible, check your control panel settings to ensure hidden files are displayed. If the file does not exist, you can create it within the File Manager.
  3. Edit .htaccess: If you find the .htaccess file, edit it by right-clicking and selecting the 'Edit' option. If you're creating a new file, name it .htaccess and open it for editing.
  4. Add the Redirect Code: With the .htaccess file open, add the following lines of code below any existing 'RewriteEngine On' line. If there's no 'RewriteEngine On' present, add it at the beginning of the file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Once you've added the above code, save the changes to your .htaccess file. This code checks if HTTPS is off (meaning traffic is on HTTP) and then applies a 301 redirect to send all incoming requests to the HTTPS version of your website.

Note: After implementing the HTTPS redirect, it's a good practice to test your website to ensure that the redirect is functioning correctly. If you encounter any issues or need assistance, our support team is here to help.

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Setting Timezone with .htaccess

Setting Your Timezone Using .htaccess For precise control over the timezone settings of your PHP...