Skip to main content

How to Redirect HTTP Traffic to HTTPS

You can redirect all incoming HTTP traffic to the HTTPS version of your website to ensure visitors always connect securely. This process is performed at the server level or via your web server configuration to ensure that both the non-secure and...

You can redirect all incoming HTTP traffic to the HTTPS version of your website to ensure visitors always connect securely. This process is performed at the server level or via your web server configuration to ensure that both the non-secure and secure versions of your site point to the same content.

Before you begin

You will need:

  • A valid SSL certificate installed for your domain.

  • Access to your website's hosting control panel or configuration files.

Redirecting via your web server configuration

Depending on your hosting environment, you can use the .htaccess file (for Apache servers) or a configuration file to manage the redirect.

Using an .htaccess file

If your website uses an Apache web server, you can use the mod_rewrite module to redirect all traffic.

  1. Access your website's root directory using a File Manager or FTP client.

  2. Locate the .htaccess file in the root directory.

  3. Open the file and add the following code at the beginning of the file:

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

  1. Save the changes to the file.

Confirm the result

To verify that the redirect is working correctly:

  • Open a web browser and type your website's address starting with http:// (e.g., http://example.com).

  • Observe the browser address bar; it should automatically change to https://example.com.

  • Test a specific internal page (e.g., http://example.com/about). It should redirect to the corresponding https:// version of that page.

Limitations

  • This procedure does not automatically fix "Mixed Content" warnings. If your site loads images or scripts from http:// sources, those specific elements will not be secure even if the page itself loads over HTTPS.

  • This redirect does not change the underlying security of your site; it only ensures that users are directed to the secure version of your content.

Did this answer your question?