Force HTTPS for your site

https, ssl, htaccess, redirect, mixed content · 0 found this helpful

Your free SSL certificate lets visitors use https://, but nothing makes them. Forcing HTTPS redirects every http:// request to the secure address. Browsers also stop showing "Not secure".

Before you start

Option 1: Ask us

Open a request at https://barbrick.ca/submitticket.php and we'll turn it on for you, usually the same day.

Option 2: .htaccess

Open public_html/.htaccess in Files and add this near the top:

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

To combine HTTPS with a preferred hostname in one hop, see www or no www.

WordPress

  1. Change the WordPress Address and Site Address to https:// in Settings → General, or see Change a WordPress site's URL.
  2. Add the rule above.
  3. Fix mixed content (below).

Mixed content

If the padlock shows a warning, the page loads some images or scripts over http://. Open your browser's developer console to find them, and change the links to https://. In WordPress, run a dry run first:

wp search-replace 'http://example.ca' 'https://example.ca' --dry-run

If something goes wrong

  • Redirect loop: a CDN or proxy handles HTTPS itself. Remove the rule or use the X-Forwarded-Proto header check your provider documents.
  • Some pages still insecure: hard-coded http:// links in the content or theme.
  • Email links broke: they didn't. Email isn't affected by site HTTPS.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.