--- title: Host slug: Web/HTTP/Headers/Host tags: - header http 参考 host translation_of: Web/HTTP/Headers/Host ---
Host 请求头指明了请求将要发送到的服务器主机名和端口号。
如果没有包含端口号,会自动使用被请求服务的默认端口(比如HTTPS URL使用443端口,HTTP URL使用80端口)。
所有HTTP/1.1 请求报文中必须包含一个Host
头字段。对于缺少Host
头或者含有超过一个Host
头的HTTP/1.1 请求,可能会收到{{HTTPStatus("400")}}(Bad Request)状态码。
Header type | {{Glossary("Request header")}} |
---|---|
{{Glossary("Forbidden header name")}} | yes |
Host: <host>:<port>
Host: developer.mozilla.org
规范 | 标题 |
---|---|
{{RFC("7230", "Host", "5.4")}} | Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing |
{{Compat("http.headers.Host")}}