Redirecting HTTP to HTTPS

After setting up a SSL certificate on your website, you can automatically redirect all HTTP traffic to the HTTPS version of your website. This article shows how to set up this redirect with or without Wordpress.
Note: Before redirecting, please make sure there are no Insecure Content errors on the HTTPS version of the site. See our support article on Updating HTTP Hardlinks.

Basic HTTPS Redirection

Create an '.htaccess' file inside your public_html directory if one is not already located there. Enter the following code at the bottom of this file and save:
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

For WordPress Sites

Plugins

WordPress has many plugins that will handle HTTPS redirection for you. We recommend using the Really Simple SSL plugin. For step-by-step instructions on using this plugin, see our support article here.

Manual Setup

If you prefer not to use a plugin, HTTPS redirection can be achieved by doing the following.
  1. Add the following line inside your wp-config.php file and save
    define('FORCE_SSL_ADMIN', true);
  2. Add the following two lines inside your .htaccess file and save
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  3. Log into your WordPress Admin Dashboard
  4. Navigate to Settings > General
  5. Change "http" to "https" at the beginning of both Wordpress address and site address URLs.
  6. Click "Save Changes" at the bottom of the page

Updating Google Analytics and Search Console

Google analytics and search console track sites by the full URL (including the protocol) rather than just the domain, so you will need to update your URL in both systems in order to keep tracking data accurately.

Google Analytics

  • Sign in to your account and navigate to the property for the site.
  • Navigate to Admin > Property Settings
  • Under "Default URL" select the dropdown for the protocol and change it to HTTPS.
  • Click "Save".

Search Console

In Search Console it's not possible to update the protocol for the existing property, so you will need to add a new property for the secure site.
  • Sign in to Search Console.
  • Click "Add a Property".
  • Select Website and enter you exact URL into the text box, e.g. 'https://yourdomain.com'. If your URL uses 'www.' include that too.
  • Verify the site using your preferred method.

Related Links

Did you find this article helpful?