I have several websites that share an htaccess file (Drupal multisite), and would like to redirect several of them to the https version of the sites. I saw this solution for one domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^specific\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
I'd like to modify it to work for several domains, but am not sure whether I can do the following, or whether the lines need to be re-written:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^specific\.com [NC]
RewriteCond %{HTTP_HOST} ^another\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
I didn't want to try it, in case I blow up several live sites.
There are 2 options:
Just redirect all the domains:
RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Or target specific subdomains using [OR]
clause:
RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^specific\\.com [NC,OR] RewriteCond %{HTTP_HOST} ^another\\.com [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.