What do you call the entire first part of a URL?

jni*_*las 68 url uri terminology

If I have a URL like:

http://www.example.com:9090/test.html
Run Code Online (Sandbox Code Playgroud)

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?

d4n*_*yll 68

它被称为原点.


更一般地说,这里是URL的不同部分,如下所示window.location.(所以至少根据Javascript的调用方式)

protocol://username:password@hostname:port/pathname?search#hash
-----------------------------href------------------------------
                             -----host----
-----------      origin      -------------
Run Code Online (Sandbox Code Playgroud)
  • protocol - URL的协议方案,包括最终的':'
  • hostname - 域名
  • port - 端口号
  • pathname - /pathname
  • search - ?parameters
  • hash - #fragment_identifier
  • username - 在域名之前指定的用户名
  • password - 域名前指定的密码
  • href - 整个网址
  • origin - protocol://hostname:port
  • host - hostname:port

正式定义在RFC 6454第4节中.

  • 起源似乎非常特定于浏览器上下文。这个术语使用范围更广吗?还有更多参考资料吗? (2认同)

key*_*rdP 28

我不知道它何时具有该方案的名称,但是具有该端口的主机名统称为Authority.一个很好的解释here.

  • 实际上,根据该链接,它将是"计划和权威". (2认同)

Ric*_*uen 26

  • http:// - 协议
  • www - 服务器名称(子域)
  • 示例 - 二级域(SLD)
  • com - 顶级域名(TLD)
  • 9090 - 端口号
  • /test.html - 路径

保存协议,您可以将"www.example.com"称为主机名,或者更具体地说,称为"完全限定的域名".

抛弃'9090',我个人觉得把它称为主机,因为这通常是你在HTTP请求中作为'host'标题得到的; 像'host:www.example.com:9090'.在PHP中,它将存储在$_SERVER"HTTP_HOST"或"SERVER_NAME"下的变量中.在JavaScript中,它将作为document.location.host.

一旦你投入'http://',我就不知道你能称它为什么:(


McD*_*ell 14

RFC 3986详细说明了语法组件.您引用的部分是scheme(http)和authority(www.example.com:9090).