URI and URL differences and differences between relative and absolute paths

Source: Internet
Author: User

One, URL and URI definitions :

1.URLis the global resource Locator written in English, you usually surf the Internet atIEThe address entered in the browser isURL. For example: NetEaseHttp://www.163.com is aURL.
2.URIis aWebeach of the resources available on-HTMLdocuments, images, video clips, programs,by a generic resource identifier(Universal Resource Identifier,abbreviation"URI")to locate.
Urlformat consists of the following three parts: 
The first part is the agreement(or as a service mode);
The second part is the host where the resource is storedIPAddress(Sometimes it also includes the port number);
The third part is the specific address of the host resource.
Urigenerally made up of three parts: 
The naming mechanism for accessing resources.
Host name of the storage resource.
The name of the resource itself, represented by the path。

Second, the URL and the URI Differences :

(a) A URI is a relatively broad concept, and a URL is one of the URIs,

is a subset of the URI naming mechanism, which can be said to be abstract, and specifically to use URLs to locate resources.

(b) Every resource on the web, such as pictures, documents, videos, etc., is located by Uri, where the so-called positioning refers to the specific path on the server that the resources on the web are stored on the servers relative to the host server.

(c) U RL is a string used on the Internet to describe information resource files, used on client programs and servers, to locate clients

Server, which not only locates this information resource, but also defines how to find the resource.

Popular Understanding:

URI is a resource positioning mechanism, it is relatively general positioning of resources, not limited to the client and server,

And the URL to locate all the resources on the Internet, as long as the resources on the Internet, there is a unique URL.



The difference between a relative path and an absolute path:

1. Absolute path

an absolute path is a path that a file really exists on the hard disk. For example"Bg.jpg"This picture is stored on the hard disk"E:\book\Page Layout Code\Section2Chapters"directory, then"Bg.jpg"The absolute path to this image is"E:\book\Web page Cloth\Code\Section2Chapters\bg.jpg ". Then you should use the following statement if you want to specify a background picture of a Web page using an absolute path:

<body backround= "E:\book\ page layout \ code \ Chapter 2 \ Bg.jpg ">

2. disadvantages of using absolute paths

in fact, when you are programming a Web page, you rarely use absolute paths if you use"E:\book\Web page Cloth\Code\Section2Chapters\bg.jpg "to specify the location of the background picture, browsing on your own computer may be fine, but uploading toWebbrowsing on the server will most likely not show the picture. Because uploading toWebserver, the entire Web site may not be placed on theWebServer'sEdisk, there could beDdisk orHdisk. Even if placed inWebServer'sEIntraday,WebServer'sEit doesn't have to be there."E:\book\Page Layout\Code\Section2Chapters"This directory, so the picture is not displayed when browsing the Web page.

3. relative path

In order to avoid this situation, it is often necessary to use relative paths when specifying files in a Web page. The so-called relative path is relative to its own target file location. For example, the above example,"S1.htm"referenced in the file."Bg.jpg"picture, because"Bg.jpg"the picture is relative to"S1.htm"is in the same directory, then the"S1.htm"The following code is used in the file, as long as the relative position of the two files does not change(Which means it's still in the same directory .), then no matter the uploadWebThe location of the server, the image can be displayed correctly in the browser.

<body background= "Bg.jpg" >

To give another example, suppose"S1.htm"the directory where the files are"E:\book\Page Layout\Code\Section2Chapters", while"Bg.jpg"the image is located in the directory"E:\book\Page Layout\Code\Section2Chapters\img ", then"Bg.jpg"the picture is relative to"S1.htm"file, it is in the directory where the"img"subdirectory, the statement referring to the picture should be:

<body background= "Img/bg.jpg" >

     Note: The relative path uses the "/" character as a separator character for the directory, The absolute path can use the "\" "/" character as a separator character for the directory. Because "img" directory is " 2 chapter " "img" before adding "/" Character.

Often used in relative paths". /"to represent the previous level of the directory. If you have multiple top-level catalogs, you can use multiple". /", such as"http://www.cnblogs.com/"represents the upper parent directory. Assumptions"S1.htm"the directory where the files are"E:\book\Page Layout\Code\Section2Chapters", while"Bg.jpg"the image is located in the directory"E:\book\Page Layout\Code", then"Bg.jpg"the picture is relative to"S1.htm"file, it is in the parent directory of its directory, then the statement referring to the picture should be:

<body background= ". /bg.jpg ">

to give another example, suppose"S1.htm"the directory where the files are"E:\book\Page Layout\Code\Section2Chapters", while"Bg.jpg"the image is located in the directory"E:\book\Page Layout\Code\img ", then"Bg.jpg"the picture is relative to"S1.htm"file, it is in the parent directory of the directory where the"img"subdirectory, the statement referring to the picture should be:

<body background= ". /img/bg.jpg ">


URI and URL differences and differences between relative and absolute paths

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.