什么控制从 https://www.host.com 到 https://host.com 的重定向?
What controls redirection from https://www.host.com to https://host.com?
除了 https://www.host.com to https://host.com 以外的所有东西都有效:
- host.com --> https://host.com
- www.host.com --> https://host.com
- https://host.com --> https://host.com
- https://www.host.com --> ?错误
我的 DNS 记录是这样的:
- 类型:一条记录
- 主持人:@
- 值:111.222.333.444
- 类型:CNAME 记录
- 主持人:www
- 值:host.com。
- 类型:URL 重定向记录 - 未屏蔽
- 主持人:@
- 值:http://host.com
- 类型:URL 重定向记录 - 未屏蔽
- 主机:www
- 值:http://host.com
以及一些 MX 记录。此 DNS 在 Namecheap 上,所以 我认为 URL Redirect Record
是 301 Permanent Redirect
.
此外,现在在 运行 URL 重定向记录之后,nslookup host.com
returns 两个不同的 IP 地址。
是什么控制了重定向,从 https://www to https://non-www?
在 Ubuntu 16,DigitalOcean Droplet,通过 certbot 设置 SSL。
使用 apache,您可以使用以下内容:
RewriteCond %{HTTP_HOST} ^www.exampledomain.com$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ https://exampledomain.com/ [R=301]
然后
sudo a2enmod rewrite;
sudo service apache2 restart;
发现错误。
SSL 证书缺少 www.example.com
version/domain。
由于 SSL 是通过 Let's Encrypt / Certbot 安装的,使用 sudo certbot certificates
表明 Domains:
只有非 www 版本。
所以重定向实际上在所有情况下都运行良好,除非 https
捕捉到 www 版本并由于缺少证书而抛出错误。此外,原始 post 中的重定向 3 和 4 是不必要的。
除了 https://www.host.com to https://host.com 以外的所有东西都有效:
- host.com --> https://host.com
- www.host.com --> https://host.com
- https://host.com --> https://host.com
- https://www.host.com --> ?错误
我的 DNS 记录是这样的:
- 类型:一条记录
- 主持人:@
- 值:111.222.333.444
- 类型:CNAME 记录
- 主持人:www
- 值:host.com。
- 类型:URL 重定向记录 - 未屏蔽
- 主持人:@
- 值:http://host.com
- 类型:URL 重定向记录 - 未屏蔽
- 主机:www
- 值:http://host.com
以及一些 MX 记录。此 DNS 在 Namecheap 上,所以 我认为 URL Redirect Record
是 301 Permanent Redirect
.
此外,现在在 运行 URL 重定向记录之后,nslookup host.com
returns 两个不同的 IP 地址。
是什么控制了重定向,从 https://www to https://non-www?
在 Ubuntu 16,DigitalOcean Droplet,通过 certbot 设置 SSL。
使用 apache,您可以使用以下内容:
RewriteCond %{HTTP_HOST} ^www.exampledomain.com$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ https://exampledomain.com/ [R=301]
然后
sudo a2enmod rewrite;
sudo service apache2 restart;
发现错误。
SSL 证书缺少 www.example.com
version/domain。
由于 SSL 是通过 Let's Encrypt / Certbot 安装的,使用 sudo certbot certificates
表明 Domains:
只有非 www 版本。
所以重定向实际上在所有情况下都运行良好,除非 https
捕捉到 www 版本并由于缺少证书而抛出错误。此外,原始 post 中的重定向 3 和 4 是不必要的。