I currently have a wordpress multisite setup of that consist of two sites, one is a subdomain. lets call the main domain www.domain.com and the sub domain test.domain.com
- For both domains I need to force https
- For the main domain I also need to enforce both ssl and www so that it becomes https://www.domain.com
The main issue I am having is when I enter https://test.domain.com this will work correctly but when I type in http://test.domain.com I get redirected to https://www.domain.com which is the main website and not the subdomain website.
<IfModule mod_rewrite.c>
RewriteEngine On
# for subdomains
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(test\.domain\.co)$ [NC]
RewriteRule ^.*$ https://%1%{REQUEST_URI} [R,L]
# for main domains
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^domain\.co$ [NC]
RewriteRule ^.*$ https://www.domain.co%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
http://wordpress.stackexchange.com
rather then SO. – Jeet