サーバーでSSLを有効にして、リダイレクト全体で.htaccessをセットアップしてドメイン(選択したクエリ文字列/ページを保持)を設定し、すべてのトラフィックをhttpsに送信しました。
これは、1つの例外を除いてほとんど機能します
http://www.domain > https://www.domain (Works)
https://www.domain (No redirect works)
http://domain > http://www.domain (no sub domain on initial request redirects to sub domain as SSL only covers the www. sub not *.domain)
https://domain > http://domain (fails doesn't prepend the www. sub domain if missing)
私はこれが盲目的に単純なものであると確信しています.
現在の .htaccess
RewriteEngine on
RewriteBase /
#determine if page is supposed to be http
#if it has p=home or p=home1 or qqq=home in querystring
#RewriteCond %{QUERY_STRING} (^|&)(p=home1?|qqq=home)(&|$) [NC,OR]
#or if query string is empty
#RewriteCond %{QUERY_STRING} ^$
#set env var to 1
#RewriteRule ^ - [E=IS_HTTP:1]
#all pages that are supposed to be http redirected if https
RewriteCond %{HTTPS} on
RewriteCond %{ENV:IS_HTTP} 1
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
#all other pages are sent to https if not already so
RewriteCond %{HTTPS} off
RewriteCond %{ENV:IS_HTTP} !1
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
どんな提案でも大歓迎です。
サブページを処理するこれも持っていたので、誰かがhttp://www.domain/index.php?p=aboutにアクセスすると、 https://www.domain/index.php?p=aboutにリダイレクトされ ます。現在の htaccess は、現時点ではクエリ文字列リダイレクタを扱っていませんが、今のところサブ ドメインの問題に焦点を当てています。
前の .htaccess
RewriteEngine on
RewriteBase /
#all pages that are supposed to be http redirected if https
RewriteCond %{HTTPS} on
RewriteCond %{ENV:IS_HTTP} 1
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
#all other pages are sent to https if not already so
RewriteCond %{HTTPS} off
RewriteCond %{ENV:IS_HTTP} !1
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
これまでに投稿された回答を使用して.htaccessを更新しました
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
#determine if page is supposed to be http
#if it has p=home or p=home1 or qqq=home in querystring
#RewriteCond %{QUERY_STRING} (^|&)(p=home1?|qqq=home)(&|$) [NC,OR]
#or if query string is empty
RewriteCond %{QUERY_STRING} ^$
#set env var to 1
RewriteRule ^ - [E=IS_HTTP:1]
RewriteCond %{HTTPS} on
RewriteCond %{ENV:IS_HTTP} 1
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
#all other pages are sent to https if not already so with the
#host name set to www.domain.com
RewriteCond %{HTTPS} off
RewriteCond %{ENV:IS_HTTP} !=1
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=302,L]