php 跨区域,如何构造PHP的内容包括在非安全(http://)和安全(https://)区域以及跨多个目录使用?...
只需使用//example.com/foo.blah即可.
< img id =“sample-image”src =“// /media/sample-image.png”/>
很明顯,HTTP是協(xié)議,但存在其他協(xié)議,如GOPHER,HTTPS,FTP等……
而不是在gopher URL gopher://example.com上,您只需鏈接到//example.com,協(xié)議就可以在沒有它的情況下工作.如果要從HTTPS鏈接到HTTP內(nèi)容,則應(yīng)指定協(xié)議.
從長遠來看,這可能是有趣的,例如,如果另一個協(xié)議出現(xiàn)與HTTP幾乎相同的工作(例如,谷歌試圖制作spdy://),您將不得不更新所有代碼.當(dāng)您特別需要從該協(xié)議獲取內(nèi)容時使用特定協(xié)議,您可能會在未來5年內(nèi)避免此問題.
RFC for URL,RFC3986中描述了相對URL:
4.2. Relative Reference
A relative reference takes advantage of the hierarchical syntax
(Section 1.2.3) to express a URI reference relative to the name space
of another hierarchical URI.
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
/ path-absolute
/ path-noscheme
/ path-empty
The URI referred to by a relative reference, also known as the target
URI, is obtained by applying the reference resolution algorithm of
Section 5.
A relative reference that begins with two slash characters is termed
a network-path reference; such references are rarely used. A
relative reference that begins with a single slash character is
termed an absolute-path reference. A relative reference that does
not begin with a slash character is termed a relative-path reference.
A path segment that contains a colon character (e.g., “this:that”)
cannot be used as the first segment of a relative-path reference, as
it would be mistaken for a scheme name. Such a segment must be
preceded by a dot-segment (e.g., “./this:that”) to make a relative-
path reference.
要了解“路徑”,“權(quán)限”和“方案”的含義,請參閱同一RFC中的圖表:
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
所有這一切都假設(shè)您正在使用多個域,因為有關(guān)< img src =“./ relative / url / foo.png”>的問題.或img src =“/ absolute / path / while / domain / relative / foo.png”已多次回答.
總結(jié)
以上是生活随笔為你收集整理的php 跨区域,如何构造PHP的内容包括在非安全(http://)和安全(https://)区域以及跨多个目录使用?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 无法连接终端授权服务器,许可证已过期的客
- 下一篇: 前台登录账号改变时迅速清空记录的登录密码