Posted by billp44ruby on July 21, 2015 at 6:46pm
I've got a multisite installation set up in a subdomain implementation. I've got an SSL certificate on the subdomain and I'd like to make sure all http traffic that comes at the site is redirected to https. My research shows that in normal implementation, an update to the .htaccess file would be the route to go. But since there is a single .htaccess file for the Drupal code, I'm not sure how to make this work only for my subdomain implementation.
Any suggestions?
Comments
use RewriteCond %{HTTP_HOST}
You can specify the domain you want to use with the RewriteRule using a condition right before it.
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
This works for multisite to
This works for multisite to redirect a specific domain, and leave others untouched.
You may need to edit it for a subdomain.
To redirect all www. and non-www. requests to https://non-www :
RewriteCond %{HTTP_HOST} ^www.SPECIFICDOMAIN.com$ [NC,OR]RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.)$ https://SPECIFICDOMAIN.com/$1 [L,R=301]
To redirect all www. and non-www. requests to https://www :
RewriteCond %{HTTP_HOST} ^www.SPECIFICDOMAIN.com$ [NC,OR]RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.)$ https://www.SPECIFICDOMAIN.com/$1 [L,R=301]
In each case, replace SPECIFICDOMAIN with your domain
+1 to eporama. That worked
+1 to eporama. That worked for me!
Thank you keva!
Your example solved what we spent a couple days trying to track down an answer to.
HTTP to HTTPS for Drupal 8 multisite
This doesn't work for Drupal 8.
Any idea how it should look in Drupal 8?