.htaccess 对我来说,秩序似乎无关紧要https://www 重新使用
问题的答案基本上是这样的:.htaccess 对我来说,秩序似乎无关紧要https://www 重新使用,.htaccess,ssl,.htaccess,Ssl,问题的答案基本上是这样的: 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=
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]
第二种说法是,如果你只有一个被认证的域,那么你应该重新考虑这个顺序
就我而言,我只有https://www.example.com
但不适用于https://example.com
。我正在使用上述.htaccess
设置,因此我没有颠倒顺序
当我输入http://example.com
我希望它首先被重定向到https://example.com
(因为有L
标志)并抛出如下警告
令我惊讶的是,它被正确地重定向到https://www.example.com
为什么不重定向到
https://example.com
并抛出警告?@anubhava我删除了浏览器缓存,用另一个我从未使用过的浏览器在inkognito模式下进行了尝试。它们都如上所述重定向。@anubhava好的,我检查了缓存禁用,第一个请求是http://example.com
状态为301
。接下来是https://www.example.com
请求状态为200
。没有http://www.example.com
或ahttps://example.com
请求。我怀疑有其他规则/代码从http://example.com
至https://www.example.com
在您的系统中