订单似乎对https:// www重定向没有好处?

时间:2018-09-02 10:40:24

标签: .htaccess ssl

在问题htaccess redirect to https://www中,答案基本上是这样的:

RewriteEngine On

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.

RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

第二个higest upvoted answer指出,如果您只有一个经过认证的域,则应遵循该顺序。

就我而言,我只有https://www.example.com的SSL证书,而没有https://example.com的SSL证书。我正在使用以上.htaccess设置,因此我没有颠倒顺序。

当我输入http://example.com时,我希望它首先被重定向到https://example.com(由于L标志)并发出类似的警告

enter image description here

令我惊讶的是,它已正确重定向到https://www.example.com

为什么这不重定向到https://example.com并引发警告?

0 个答案:

没有答案