iPhone上URL Schemes的作用为应用程序提供了一个其他应用程序或者safari可以启动他的方法.
--http://blog.sina.com.cn/s/blog_5673c12f0100qd6i.html
iPhone / iOS SDK 最酷的特性之一就是应用将其自身”绑定”到一个自定义 URL scheme 上,该 scheme 用于从浏览器或其他应用中启动本应用。
--http://objcio.com/blog/2014/05/21/the-complete-tutorial-on-ios-slash-iphone-custom-url-schemes/
URL
http://en.wikipedia.org/wiki/Uniform_resource_locator
Syntax
Every HTTP URL consists of the following, in the given order. Several schemes other than HTTP also share this general format, with some variation.
- the scheme name (commonly called protocol, although not every URL scheme is a protocol, e.g. mailto is not a protocol)
- a colon, two slashes,[9][8]
- a host, normally given as a domain name[10] For example, http://www.example.com/path/to/name would have been written http:com/example/www/path/to/name[7] but sometimes as a literal IP address
- optionally a colon followed by a port number
- the full path of the resource
The scheme says how to connect, the host specifies where to connect, and the remainder specifies what to ask for.
For programs such as Common Gateway Interface (CGI) scripts, this is followed by a query string,[11][12] and an optional fragment identifier.[13]
The syntax is:
- scheme://[user:password@]domain:port/path?query_string#fragment_id
Component details:
- The scheme, which in many cases is the name of a protocol (but not always), defines how the resource will be obtained. Examples include http, https, ftp, file and many others. Although schemes are case-insensitive, the canonical form is lowercase.
- The domain name or literal numeric IP address gives the destination location for the URL. A literal numeric IPv6 address may be given, but must be enclosed in [ ] e.g.[db8:0cec::99:123a].
- The domain google.com, or its numeric IP address 173.194.34.5, is the address of Google's website.
- The domain name portion of a URL is not case sensitive since DNS ignores case:
- http://en.example.org/ and HTTP://EN.EXAMPLE.ORG/ both open the same page.
- The port number, given in decimal, is optional; if omitted, the default for the scheme is used.
- For example, http://vnc.example.com:5800 connects to port 5800 of vnc.example.com, which may be appropriate for a VNC remote control session. If the port number is omitted for an http: URL, the browser will connect on port 80, the default HTTP port. The default port for an https: request is 443.
- The path is used to specify and perhaps find the resource requested. This path may or may not describe folders on the file system in the web server. It may be very different from the arrangement of folders on the web server. It is case-sensitive,[14] though it may be treated as case-insensitive by some servers, especially those based on Microsoft Windows.
- If the server is case sensitive and http://en.example.org/wiki/URL is correct, then http://en.example.org/WIKI/URL or http://en.example.org/wiki/url will display an HTTP 404 error page, unless these URLs point to valid resources themselves.
- The query string contains data to be passed to software running on the server. It may contain name/value pairs separated by ampersands, for example
- ?first_name=John&last_name=Doe.
- The fragment identifier, if present, specifies a part or a position within the overall resource or document.
- When used with HTML, it usually specifies a section or location within the page, and used in combination with Anchor elements or the "id" attribute of an element, the browser is scrolled to display that part of the page.
The scheme name defines the namespace, purpose, and the syntax of the remaining part of the URL. Software will try to process a URL according to its scheme and context. For example, a web browser will usually dereference the URL http://example.org:80 by performing an HTTP request to the host at example.org, using port number 80.
Other examples of scheme names include https, gopher, wais, ftp. URLs with https as a scheme (such as https://example.com/) require that requests and responses will be made over a secure connection to the website. Some schemes that require authentication allow a username, and perhaps a password too, to be embedded in the URL, for exampleftp://asmith@ftp.example.org. Passwords embedded in this way are not conducive to security, but the full possible syntax is
- scheme://username:password@domain:port/path?query_string#fragment_id
Other schemes do not follow the HTTP pattern. For example, the mailto scheme only uses valid email addresses. When clicked on in an application, the URLmailto:bob@example.com may start an e-mail composer with the address bob@example.com in the To field. The tel scheme is even more different; it uses the public switched telephone network for addressing, instead of domain names representing Internet hosts.
棒棒哒~
http://segmentfault.com/q/1010000003056554
在URL里面,当然是search
在前,hash
在后。
'?search=a' 整个地是location.search
,'#hash'整个地才是location.hash
关于URI的格式是由RFC 3986规定的。
其中?search=a
这种叫query
,#hash
叫fragment
。
* query
的规定是以第一个?
开始,至行尾或#
结束。
* fragment
以#
为开始,行尾为结束。
也就是说query
必须在fragment
之前。
另外根据query
和fragment
字符限定的规定,两者中都可以含有/
和?
,但不可以含有#
。(还有其它的限制,这里是简要的说法,因为我们此处要讨论以?
和#
开头的字串)所以Angular.js中出现的http://example.com/#/some/path?search=a#hash
实际上是不符合RFC规定的。但是此处是为了给不支持HTML5的浏览器提供兼容支持,也是无奈之举。
对URL在#之后的部分做变动不会刷新页面,你可以在浏览器的console里分别输入window.location.hash="#hash"
和window.location.search="?sa"
执行看看结果,后者是会刷新页面的。HTML5有History API可以不刷新页面对URL进行修改,就不用加一个#
号来防刷新了。另外有#
分割做单页应用的时候服务器那边也好处理……
hash
的部分是不会传到服务器的(没刷新),即正常请求的话,#
后面的部分服务器是接收不到的
当然js
检测hash
然后发起不同的请求另说.
这个不存在什么规范的问题吧,看自身怎么架构的吧
uri是url的超集
http://www.cnblogs.com/hust-ghtao/p/4724885.html
“A URI 可以进一步被分为定位符、名字或两者都是. 术语“Uniform Resource Locator” (URL) 是URI的子集, 除了确定一个资源,还提供一种定位该资源的主要访问机制(如其网络“位置”)。“
- 让URI能成为URL的当然就是那个“访问机制”,“网络位置”。e.g.
http://
orftp://
.。
总结
下面到了回答问题的时候了:
当我们替代web地址的时候,URI和URL那个更准确?
基于我读的很多的文章,包括RFC,我想说URI更准确。
别急,我有我的理由:
我们经常使用的URI不是严格技术意义上的URL。例如:你需要的文件在files.hp.com
. 这是URI,但不是URL--系统可能会对很多协议和端口都做出正
确的反应。
你去http://files.hp.com
和ftp://files.hp.com
.可能得到完全不同的内容。这种情况可能更加普遍,想想不同谷歌域名上的不同服务啊。
所以,用URI吧,这样你通常技术上是正确的,URL可不一定。最后“URL”这个术语正在被弃用。所以明智吧少年!