方案相对URL [英] Scheme relative URL

查看:60
本文介绍了方案相对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于方案相对URL,有很多关于SO的问题,但是我不明白在这些情况下会发生什么:

There are a lot of questions on SO regarding scheme relative URL, but I don't understand what will happen in these scenarios:

1)我在HTTPS上单击 href ="//example.com/"(example.com没有SSL(它是HTTP),因此浏览器将尝试打开 HTTPS://example.com/(因为它想匹配当前方案),如果没有HTTPS方案,它将打开 HTTP://example.com/?

1) I am on HTTPS clicking on href="//example.com/" (example.com doesn't have SSL (it's HTTP), so browser will try to open HTTPS://example.com/ (because it wants to match the current scheme) and if there won't be HTTPS scheme it will open HTTP://example.com/?

2)当目标//example.com/仅是HTTPS时,反之亦然,从HTTP到HTTPS.如果目标目标没有HTTP,浏览器会打开HTTPS吗?

2) Vice-versa going from HTTP to HTTPS, when the target //example.com/ is only HTTPS. Will browser open HTTPS if the destination target does not have HTTP?

推荐答案

浏览器将尝试使用当前使用的相同方案来打开URL.如果当前使用HTTPS,它将使用HTTPS请求URL,反之亦然.如果目标服务器不支持该方案,则只会失败.如果服务器仅支持HTTPS,通常意味着它实施 HTTPS;如果您对该服务器进行HTTP查询,它通常会经常重定向到同一页面的HTTPS版本.不过,这完全取决于服务器.

The browser will try to open the URL using the same scheme it's currently on; if it's currently on HTTPS, it will request the URL with HTTPS and vice versa for HTTP. If the target server does not support that scheme, it will simply fail. In case of a server which only supports HTTPS, that usually means that it enforces HTTPS; if you make an HTTP query to that server it often simply redirects to the HTTPS version of the same page. That's entirely up to the server to do though.

如果服务器仅支持HTTP,通常意味着它根本没有HTTPS.在这种情况下,HTTPS请求将完全失败,浏览器将显示一条错误消息,内容为无法建立安全连接/无法连接至服务器".

If a server only supports HTTP, that usually means that it doesn't have HTTPS at all. In that case an HTTPS request would simply fail and the browser will display an error message along the lines of "couldn't establish a secure connection/couldn't connect to server".

这篇关于方案相对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆