Absolute path, root relative path, and document relative path

Source: Internet
Author: User

The absolute path is the full path that includes the Server Protocol (in this example, http). For example, the full path of "Hong Neng online-computer Park" is http://www.hongen.com/pc/index.htm. if you want to link a document outside the site, use absolute paths.

 

The relative path includes the Root relative path (Site Root) and Document relative path (Document.

 

As mentioned above, when editing a webpage on a local disk, You need to select a folder to define the local site and simulate the root folder on the server, the system determines the local file location of all links based on this folder, and the root in the relative path refers to this folder.

 

The path of the root relative path (also known as relative and directory) is/The path starts from the root directory of the current site. For example, the myweb directory of the D disk we created earlier is the site named "myweb". Then, the path "/index.htm" indicates that the file location is D: \ myweb \ index.htm. The root relative path applies to files in the environment frequently when the link content is changed, so that the link can still take effect even if the files in the site are moved.

 

If the directory structure is too deep, it is better to use the relative path when referencing the files under the root directory. For example, a page file references a graph in the img directory under the root directory, in the current page with the relative path of the document is: "http://www.cnblogs.com/http://www.cnblogs.com .. /img/a.gif, and the relative path is expressed as "/img/a.gif.

 

Note: When previewing a file, content linked with the root relative path is not displayed in the local browser, because the browser does not recognize the root folder of the site as a server.

 

In this case, we can virtualize the root directory of the site into a disk. For example, if you want to browse files under D: \ myweb, you can select "run" in the Windows "start" menu to bring up the "run" dialog box.

 

Enter "subst I: d: \ myweb", and the myweb folder under drive D is virtualized as an I disk. view the webpage under drive I in a browser, the content linked with the root relative path can be displayed normally.

  

The relative path of a document refers to the folder containing the current document, which is calculated based on the folder where the current webpage is located. For example, if the current webpage is located at D: \ myweb \ mypic, then:

 

A.htm indicates D: \ myweb \ mypic \ a.htm;

 

"../A.htm" is equivalent to D: \ myweb \ a.htm, where"../"Indicates the first-level folder on the current folder.

 

"Img/a.gif" or "./img/a.gif" means D: \ myweb \ mypic \ img \ a.gif. "img/" means the img folder under the current folder. "./"Indicates the current folder.

 

The relative path of a document is the simplest path. Generally, it is used to link documents stored in the same folder.

 

From: http://www.cftea.com/c/2009/02/V9RJ3UFJ78BXD865.asp

 

 

Relative Path and absolute path

 

I need to use a USB flash drive to run a program on different computers, and this program needs to call another program of the USB flash drive. Some programs on different computers recognize it as an e disk, in this case, you need to specify the path E:, and some computers recognize it as H disks. This requires you to manually change the path to H:, which is very inconvenient. Please write a relative path or absolute path highly, help me solve this problem. Don't worry about recognizing the drive letter. At that time, the program will be able to run the relevant program in the USB flash drive (current disk). Thank you.

Question added:

I thought about this method, but it is not easy to use. I have 98.2K and XP

Best Answer

 

Absolute path: the path starting with the drive letter, as shown in figure
C: \ windows \ system32 \ cmd.exe
Relative Path: indicates the path starting from the current path. If the current path is C: \ windows
To describe the preceding path, enter
System32 \ cmd.exe
In fact, the strict relative path should be written
. \ System32 \ cmd.exe
Here, "." indicates the current path. It can be omitted in the case of a channel. It cannot be omitted only in special cases.
Assume that the current path is c: \ program files
To call the preceding command, enter
.. \ Windows \ system32 \ cmd.exe
Where,... is the parent directory.
If the current path is c: \ program files \ common files
Enter
.. \ Windows \ system32 \ cmd.exe

In addition, there is a special absolute path that does not contain the drive letter, such
\ Windows \ system32 \ cmd.exe
No matter what the current path is, the specified program is automatically searched from the root directory of the current disk.

 

From: http://zhidao.baidu.com/question/54621865.html? Fr = ala0

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.