开发者

Are the terms "URL" and "path" interchangeable?

If you think they are not, please give an开发者_如何转开发 example for a string that can be called "URL" and not "path" and one that can be called "path" and not "URL".


URL: Are the terms "URL" and "path" interchangeable?
Path: /questions/3491674/are-the-terms-url-and-path-interchangeable


Schema: http
Host: stackoverflow.com

They're all different parts of the URL, they're not interchangeable.


Getting if from the source: RFC 1738

An HTTP URL takes the form:

    http://<host>:<port>/<path>?<searchpart>


A URI (including URLs though the distinction is irrelevant in most cases, and URLs are always URIs so mostly we just talk about URIs these days) is a globally-unique identifier of a resource.

E.g. http://example.net/foo/bar?a=b

A path is part of the URI, in the above example the path is /foo/bar

A URI reference is a means to textually communicate a URI. It can be absolute, in which case it is the same as the URI, and hence it will resolve to the same URI in any context. It can be an absolute-path, like /foo/bar?a=b in which case it will resolve to the same URI in any context sharing the same scheme, host and port. It can be relative such as ../bar?a=b and it can be scheme-relative such as ://example.net/foo/bar?a=b which resolves to the example URI above from any HTTP base URI, but not if the base URI is HTTPS or another scheme.


URL is mostly a "web specific term", but path can be used in a lot of different contexts, filesystem path, XML [x]path, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜