Handling Wordpress MU HTTPS Directives
We’re developing an application based on the Wordpress MU framework that needs to handle HTTPS requests separately. I’m not a subject expect, so I had to dig around to figure out the best approach for explicitly defining HTTPS rules for our mainsite versus subdomains.
Here is what I came up with:
- Open up your .htaccess file
- Enter the following rule to default your mainsite to HTTPS:
RewriteEngine on RewriteCond %{HTTPS} !on RewriteCond %{HTTP_HOST} ^(www\.)?mainsite\.com RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] - Save.
Alternatively, if you need to explicitly define subdomains with the same rule, you can use the following variation:
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^((www|subdomain)\.)?mainsite\.com
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
We opted for %HTTP_HOST% over %SERVER_NAME%. In case you’re wondering what the difference is between the two, I found a great explanation on StackOverflow.





