.htaccess rule to force SSL on only certain domains

I’m running a WordPress multisite network that allows users to optionally use a custom domain name on their websites. Users that opt not to use a custom domain are assigned a subdomain of the WP install (e.g.: fred.example.com, with example.com being the URL the WP multisite network is installed on).

I have a wildcard SSL configured for the main domain, but I do not have certificates available for custom domain names.

What I need is a htaccess rule to force traffic to https if the request is for either example.com or *.example.com, but not if the request is coming in using a custom domain.

It should work as follows:

  • http://example.com/*https://example.com/*
  • http://foo.example.com/*https://foo.example.com/*
  • http://customdomain.com/*http://customdomain.com/*

Read more here: .htaccess rule to force SSL on only certain domains

Leave a Reply

Your email address will not be published. Required fields are marked *