在这种情况下,“对服务器的两个请求"的实际含义是什么? [英] What's the actual meaning of 'two requests to the server' in this context?

查看:17
本文介绍了在这种情况下,“对服务器的两个请求"的实际含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 w3schools.com 上的 HTML 链接章节上学习 HTML 教程时,我看到了以下内容句子:

While studying HTML tutorial on HTML Links Chapter on w3schools.com I saw following sentence:

如果子文件夹地址上没有正斜杠,您可能会向服务器生成两个请求.很多服务器会自动给地址加一个正斜杠,然后创建一个新的请求.

Without a forward slash on subfolder addresses, you might generate two requests to the server. Many servers will automatically add a forward slash to the address, and then create a new request.

我没明白锚标签的 href 属性中提到的 URL 中缺少尾部斜杠如何传递两个请求的含义?

I didn't get the meaning of how two request can be passed if trailing slash is missing in the URL mentioned in href attribute of anchor tag?

推荐答案

接收到 /foo 请求的 Web 服务器可能会查看它并看到它的 foo 是实际上是一个文件夹,并决定这个文件夹的实际地址是/foo/.所以它会响应一个 302 重定向到客户端并告诉它获取 /foo/ 代替:

A web server receiving a request for /foo may look at it and see that its foo is actually a folder, and decide that the actual address for this folder is /foo/. So it will respond with a 302 redirect to the client and tell it to fetch /foo/ instead:

  1. 浏览器到服务器:GET/foo
  2. 服务器到浏览器:302 Found,位置:/foo/
  3. 浏览器到服务器:GET/foo/
  4. 服务器到浏览器:200 OK,content...

服务器是否执行此操作取决于您的服务器.最终,您应该始终使用链接中项目的实际 URL,不要依赖服务器为您隐式地修复它".

Whether the server does this or not depends on your server. Ultimately you should always use the actual URL of items in your links, don't rely on a server to "fix it" implicitly for you.

这篇关于在这种情况下,“对服务器的两个请求"的实际含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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