重定向 http=>https(非 www)+ www https=> 非 www https(www 无证书)
Redirecting http=>https (non-www) + www https=> non-www https (no certificate for www)
我看过很多关于重写的文章。都好。但是 none 涵盖了这种确切情况。所以这是我的问题:希望你能帮忙。因为我无法让它工作。
- 我们 运行 网站位于 domain.com(非 www)
- 我们设置了 ssl(因此仅限 https)
- 我们有 1 个非 www 版本(不是 www 版本)的证书
当我们执行所有四个测试用例时,3个OK,1个不
- http://domain.com => https://domain.com =>
- http://www.domain.com => https://domain.com => 好的
- https://domain.com => 好的
- https://www.domain.com => 错误。证书警告不安全
问题:现在为什么数字 4 https://www 给我这个错误。我希望第一条规则能够接收并将我们发送到非 www 版本。我该如何解决这个问题?
感谢任何帮助;P 肖恩
这是我当前的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect www to non-www first
# Added based on article
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/ [R=301,NE,L]
# Then redirect http to https (if necessary)
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [R=301,L]
</IfModule>
您可以在您的 .htaccess 中使用它:
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect www to non-www first
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/ [R=301,NE,L]
# Then redirect http to https (if necessary)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
</IfModule>
但是对于证书错误,您无能为力。
阅读:
仅通过 htaccess 或 nginx conf 是无法解决的。
需要一个证书来涵盖域的 www 和非 www 版本
因此,一个通配符证书或一个多域证书,其中 www 和非 www 都作为一个单独的域包含在内
希望对您有所帮助
我看过很多关于重写的文章。都好。但是 none 涵盖了这种确切情况。所以这是我的问题:希望你能帮忙。因为我无法让它工作。
- 我们 运行 网站位于 domain.com(非 www)
- 我们设置了 ssl(因此仅限 https)
- 我们有 1 个非 www 版本(不是 www 版本)的证书
当我们执行所有四个测试用例时,3个OK,1个不
- http://domain.com => https://domain.com =>
- http://www.domain.com => https://domain.com => 好的
- https://domain.com => 好的
- https://www.domain.com => 错误。证书警告不安全
问题:现在为什么数字 4 https://www 给我这个错误。我希望第一条规则能够接收并将我们发送到非 www 版本。我该如何解决这个问题?
感谢任何帮助;P 肖恩
这是我当前的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect www to non-www first
# Added based on article
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/ [R=301,NE,L]
# Then redirect http to https (if necessary)
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [R=301,L]
</IfModule>
您可以在您的 .htaccess 中使用它:
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect www to non-www first
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/ [R=301,NE,L]
# Then redirect http to https (if necessary)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
</IfModule>
但是对于证书错误,您无能为力。
阅读:
仅通过 htaccess 或 nginx conf 是无法解决的。
需要一个证书来涵盖域的 www 和非 www 版本
因此,一个通配符证书或一个多域证书,其中 www 和非 www 都作为一个单独的域包含在内
希望对您有所帮助