Netlify社区经常提出另一个问题."Netlify可以将流量从http重定向到https而不强制使用SSL(TLS)吗?"
获得证书后,您可以选中一个框以强制使用TLS.这将设置从http到https的重定向,并为所有请求添加严格传输安全标头.
在完成所有设置并且他们知道不会更改其设置之前,用户不希望强制使用SSL.
当前,自2018年11月(自2018年7月起),Netlify上的所有新站点均为HTTPS ,默认情况下强制重定向已打开,您无法将其关闭。
请参阅博客文章:
而这个问题在GitHub上:
即使对于旧站点,也无法使用关闭HTTPS或关闭重定向到HTTPS的选项:
Netlify允许您强制TLS.在确定所有URL都使用https之前,建议不要"强制使用TLS"
在您确定所有网址都在前面使用"https://"之前,请不要选中"强制TLS"选项!
一旦您使用Netlify强制TLS,他们将在您的页面响应标头中设置STS(严格传输 - 安全)标头.我不会解释,但你可以在这里阅读.
要知道的主要是:
支持的浏览器收到此标头后,浏览器将阻止通过HTTP将任何通信发送到指定的域,而是通过HTTPS发送所有通信
请注意,Netlify的设置(使用强制TLS复选框)是让访问浏览器在访问日期后的1年内强制执行此操作!因此,如果您在https上有任何失败,您的网站将会遇到一些问题,直到您能够修复它们为止.
您仍然希望您的网站在添加证书后始终提供https页面,但在测试或处理问题时不会强制它.
使用已_redirects部署站点根目录下的文件(在"发布目录中,index.html旁边")将流量重定向到https.
这是该文件的一个示例
_redirects
# redirect netlify sitename to your sitename for SEO purposes,
# to avoid duplicate content. Do this for http and https
https://example.netlify.com/* https://www.example.com/:splat 301!
http://example.netlify.com/* http://www.example.com/:splat 301!
# also redirect http to https for your custom domain.
# Note that netlify automatically redirects to your custom domain from the bare domain (or vice versa), so you only need one rule here.
http://www.example.com/* https://www.example.com/:splat 301!
Run Code Online (Sandbox Code Playgroud)
netlify.toml
[[redirects]]
from = "https://example.netlify.com/*"
to = "https://www.example.com/:splat"
status = 301
force = true
[[redirects]]
from = "http://example.netlify.com/*"
to = "http://www.example.com/:splat"
status = 301
force = true
[[redirects]]
from = "http://www.example.com/*"
to = "https://www.example.com/:splat"
status = 301
force = true
Run Code Online (Sandbox Code Playgroud)
注意:
www子域(可选)www用作自定义域,以便通过任何 DNS设置充分利用Netlify CDN .http到https所有路径| 归档时间: |
|
| 查看次数: |
3665 次 |
| 最近记录: |