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.