我的htaccess文件从域名重定向到子域,然后确保它是HTTPS。当HTTPS与域名一起使用时,所有工作都可以预期:
https://example.co.uk FAILS
https://www.example.co.uk OK - https://www.example.co.uk
http://example.co.uk OK - redirects to https://www.example.co.uk
http://www.example.co.uk OK - redirects to https://www.example.co.uk
htaccess文件看起来像这样
#First rewrite any request to the wrong domain to use the correct one
RewriteCond %{HTTP_HOST} ^example\.co\.uk$
RewriteRule ^(.*)$ https\:\/\/www\.example\.co\.uk/$1 [R=301,L]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]