に一致した場合、私は、ドメインマッチとも非WWW場合は、すべてのドメインのためのWWWにhttpsに非HTTPSをリダイレクトします。htaccessの条件付きリダイレクトドメインは
ここは、www以外のものをhttpsバージョンのwwwにリダイレクトしない以外は動作するマイコードです。
注:URLにwwwを追加した場合、広告はwww 2xとなるため、非wwwとwwwバージョンのルールが分かれています。
RewriteEngine On
#all non-www to www (without HTTPS)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#non-https to https if these 2 domains matched - and since there is already www don't add it.
RewriteCond %{HTTP_HOST} ^www\.domainA\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.domainB\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#non-https to https if these 2 domains matched - and also www
RewriteCond %{HTTP_HOST} ^domainA\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^domainB\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*)$ index.html
何が問題なのですか? – anubhava
@anubhavaもし私がhttps:domainA.comにアクセスすると、それにwwwが追加されません。 –