0

The situation is a multisite with SSL and some subsites have their own domain names.

Main site is www.example.com Subsite is www.example.com/subsite1 Subsite1 has their own name of www.subsite.com Main site has SSL, subsites should also use SSL

These URLs should do:

http://www.example.com changed to https://www.example.com
http://example.com changed to https://www.example.com
https://example.com changed to http://www.example.com
https://www.subsite.com changed to https://www.subsite.com
https://example.com/subsite1 changed to https://www.subsite.com

I have existing htaccess rule to force SSL

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

The http://subsite.com does not route to https://www.subsite.com , it goes to http://www.example.com .

Site settings in multisite network admin (and that site's wp-options URLs) are set to 'www.subsite.com'.

I have also tried this, it doesn't work for all cases

RewriteEngine On
#RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR]
#RewriteCond %{HTTPS} off
#RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]

What htaccess rules should I have to perform the above rewrites? And what URL should I put in the substites Network Site settings (and wp-options for that subsite)?

(Note: I realize this is not entirely WP question, but it relates to how WP multisite works with htaccess and subsites having their own domain names, so it was posted here.)

  • So just to clarify, you can get it to redirect to HTTPS great, you can get it to handle the URLs great, but not both at the same time? I notice you're doing the reverse http -> https and https -> http depending on the domain, what's the reason behind this? The obvious solution here is to change everything over to HTTPS – Tom J Nowell Jul 14 '18 at 18:04
  • The intent is to change everything to https. The problem is that the site1.com (without www) redirects to the main site page, not to the www.site1.com (subsite) page. HTTP to HTTPS works OK, but not if you don't put in the 'www' for the subsite's domain name . – Rick Hellewell Jul 14 '18 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.