Summary of relative paths of absolute paths

Source: Internet
Author: User

You must first informRelative PathAndAbsolute pathIn the next step, we must use this concept to reference files or webpages on the same web server. Next we will give a brief introduction to these two paths.

Relative Path-Create a directory path based on the location of the webpage that references the file. Therefore, when the web pages stored in different directories reference the same file, the paths used are different, so they are called relative.

Absolute path-The directory path based on the root directory of the web site. The reason for this is absolute: When all webpages reference the same file, the paths used are the same.

ActuallyAbsolute pathAndRelative PathThe difference is that the reference point is different when the directory path is described. For all files on the website, the reference point of the root directory is the same for all files. Therefore, the path description method based on the root directory is calledAbsolute path.

The following are the special symbols used to create a path and their meanings.

"." -- Represents the current directory.
"..." -- Indicates the directory on the previous layer.
"/" -- Represents the root directory.

If you want to reference the beref.gif file in the ref.htm fileRelative PathAs follows:

./Subdir2/beref.gif

In the referenced path above, "." indicates the current directory (dir1), so "./subdir2" indicates the subdir2 under the current directory. In fact, you can also omit "./" to directly reference this method.

Subdir2/beref.gif

If you useAbsolute pathWhen the file is referenced as a reference point in the root directory, the Reference Path is as follows:

/Dir1/subdir2/beref.gif


Refer to the beref.gif FileRelative PathWhat is it?

If you want to use the beref.gif file in the ref.htm fileRelative PathAs follows:

../Subdir2/beref.gif

In the reference path above, ".." indicates the previous directory, so/dir2 "indicates the dir2 subdirectory under the previous directory. If you useAbsolute pathWhen referencing, the Reference Path is as follows:

/Dir2/berer.gif

Let's take another complicated example to compare it.Relative PathAndAbsolute path. Assume that the directory path for the website created by the reader is as follows.

We use a table to describeRelative PathAndAbsolute path.

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.