[英]htaccess redirect https://www. (https://www.example.com) to non www (https://example.com)
I'm trying to redirect all requests from http to https and all requests from www. 我正在尝试将所有请求从http重定向到https和所有请求从www重定向。 to non www (https://) but no matter what i try it is not working.
到非www(https://),但是无论我尝试什么都不起作用。 Specifically the redirect from https://www.example.com to https://example.com is not working.
特别是从https://www.example.com到https://example.com的重定向无效。 Everything else works fine.
其他一切正常。 I've tried many different ways i found here on stackoverflow and other posts on the internet but none of them are working for me.
我已经尝试过在stackoverflow和互联网上的其他帖子中找到的多种不同方式,但是没有一种对我有用。 When i go to https://www.example.com i get a certificate warning cause the certificate is issued to https://example.com .
当我转到https://www.example.com时,我收到证书警告,原因是证书已颁发给https://example.com 。 I'm really giving up on this one as i've tried it for two days now ...
我真的已经放弃了这个,因为我已经尝试了两天了...
Maybe i'm doing something completely wrong or it is something else i forgot. 也许我做的事情完全错误,或者我忘记了其他事情。 Help is much appreciated, thank you.
非常感谢您的帮助,谢谢。
This is the code i'm using right now 这是我现在正在使用的代码
RewriteEngine on
# www -> https without www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
# http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
Cheers 干杯
Arkascha had the right answer so i'm quoting his comment: Arkascha的回答是正确的,因此我引用了他的评论:
Request rewriting cannot somehow magically get you around the client side certificate validation.
请求重写无法以某种方式神奇地使您绕过客户端证书验证。 The initial requests goes to www.example.com.
最初的请求转到www.example.com。 If the client cannot validate the specified certificate for that request it issues an error to the user.
如果客户端无法验证该请求的指定证书,它将向用户发出错误。 There is no way around that.
没有办法解决。 You either need an additional certificate for that host or a wildcard certificate.
您需要该主机的其他证书或通配符证书。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.