URL 的整个第一部分怎么称呼?
如果我的 URL 如下:
http://www.example.com:9090/test.html
那么我知道 www.example.com
是主机名,但是您怎么称呼 http://www.example.com:9090
>?有某种既定的名称吗?
If I have a URL like:
http://www.example.com:9090/test.html
Then I know that www.example.com
is the host name, but what do you call http://www.example.com:9090
? Is there some kind of established name for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
它被称为起源。
更一般地说,以下是 URL 的不同部分,按照
位置
。 (所以至少根据 Javascript 的调用方式)protocol
- URL 的协议方案,包括最后的 ':'hostname
- 域名port
> - 端口号路径名
-/路径名
搜索
-?参数
hash
-#fragment_identifier
username
- 在域名之前指定的用户名password - 域名前指定的密码
href
- 整个 URLorigin
-protocol://hostname:port
host -
hostname:port
请注意,每个部分的确切命名在不同的标准中可能会有所不同。例如,RFC 6454 第 4 节中的“host”表示“主机名” ' 在上图中。
It is called the origin.
More generally speaking, here are the different parts of a URL, as per
Location
. (So at least according to how Javascript calls it)protocol
- protocol scheme of the URL, including the final ':'hostname
- domain nameport
- port numberpathname
-/pathname
search
-?parameters
hash
-#fragment_identifier
username
- username specified before the domain namepassword
- password specified before the domain namehref
- the entire URLorigin
-protocol://hostname:port
host
-hostname:port
Note that the exact naming of each part may be different in different standards. For example, 'host' in RFC 6454 section 4. means 'hostname' in the above diagram.
保存协议,可以参考 'www .example.com”作为主机名,或者更具体地说,作为“完全限定域名”。
加上“9090”,我个人更愿意将其称为主机,因为这通常是 HTTP 请求中的“主机”标头;类似于“主机:www.example.com:9090”。在 PHP 中,它将存储在“HTTP_HOST”或“SERVER_NAME”下的
$_SERVER
变量中。在 JavaScript 中,它将作为document.location.host
提供。我不知道,一旦你输入“http://”,你会怎么称呼它:(
Save the protocol, you can refer to 'www.example.com' as either the hostname or - more specifically - the 'fully qualified domain name'.
Toss in the '9090' and personally I'd be comfortable calling it the host, as that's usually what you'd get as the 'host' header in an HTTP request; something like 'host: www.example.com:9090'. In PHP it would be stored in the
$_SERVER
variable under 'HTTP_HOST' or 'SERVER_NAME'. In JavaScript it would be available as thedocument.location.host
.I don't know, what you could call it once you toss in 'http://' :(
我不知道它具有方案时的名称,但带有端口的主机名统称为
Authority
。此处
有一个很好的解释。I don't know the name for when it has the scheme, but the hostname with the port is collectively known as the
Authority
. A nice explanationhere
.RFC 3986 详细介绍了语法组件。您引用的部分是方案 (
http
) 和权限 (www.example.com:9090
)。RFC 3986 details the syntax components. The part you refer to would be the scheme (
http
) and authority (www.example.com:9090
).FWIW,.Net 框架 Uri 类适用于“GetLeftPart()”。
“方案+权限”没有一个合适的名字真是令人恼火
FWIW, the .Net framework Uri class goes for "GetLeftPart()".
It's irritating not having a proper name for "scheme + authority"
我不这么认为。如果有的话,我希望 DOM 在 window.location 类中反映这一点: https ://developer.mozilla.org/En/DOM/Window.location
I don't think so. If there was, I would expect the DOM to reflect this in the window.location class: https://developer.mozilla.org/En/DOM/Window.location
base url
在某些情况下也是一个很好的术语,但它不仅限于方案和主机,还可以选择包含路径。base url
is also a good term in some contexts, but it does not limit it to only scheme and host, but optionally can include the path.您可以在 Wikipedia 上阅读 URL 的各个部分。
您会发现
http
是协议名称,:9090
确定应在端口 #9090 等上建立连接。You can read about every part of URL on Wikipedia.
You'll find there that
http
is a protocol name,:9090
determines that the connection should be establishment on port #9090 etc.这意味着托管 example.com 的 HTTP 服务器正在使用端口
9090
来处理 HTTP 请求,它向浏览器发出指令,指示它应该通过端口 9090 而不是通常的 80 连接到该服务器。如果未指定端口则执行It means that the HTTP server hosting example.com is using the port
9090
for processing HTTP requests, it is a directive to the browser that it should connect to that server on port 9090 instead of 80 which it normally does if the port is not specified