Home > Common Problem > body text

What does the path of a file describe?

青灯夜游
Release: 2020-11-30 16:50:47
Original
16188 people have browsed it

The path of a file is used to describe: the directory location of the file on the disk, or the location in the website folder structure. Paths are divided into absolute paths and relative paths; absolute paths refer to the absolute location in a directory, which directly reaches the target location, usually the path starting from the root directory; relative paths refer to the path between the file and other files (folders) caused by the path where the file is located. path relationship.

What does the path of a file describe?

#The path of a file is used to describe: the directory location of the file on the disk, or the location in the website folder structure.

Paths are divided into absolute paths and relative paths.

Absolute path refers to the absolute location under the directory, directly reaching the target location, usually the path starting from the drive letter (root directory).

The path that completely describes the file location is the absolute path, which is the directory path based on the root directory of the web site. The absolute path name is specified from the root directory at the top of the tree directory structure to a directory or file. It consists of a series of consecutive directories separated by slashes until the directory or file to be specified. The last name is the directory or file to point to. The reason why it is called absolute means that when all web pages reference the same file, the path used is the same.

//绝对路径,指向一个因特网文件的完整 URL
<img src="https://www.w3school.com.cn/images/picture.jpg" alt="flower">
Copy after login

Relative path refers to the path relationship with other files (or folders) caused by the path where this file is located. Using relative paths can bring us a lot of convenience. HTML absolute path refers to the full path of the file with domain name.

//文件路径指向了位于当前网站根目录中 images 文件夹里的一个文件:
<img src="/images/picture.jpg" alt="flower">
Copy after login

Comparison of absolute paths and relative paths

Advantages of absolute paths in network applications:

1. Prevent websites If it is maliciously plagiarized, use an absolute path. If someone plagiarizes and collects your content, the link inside will still point to your website. Some plagiarists are lazy and even copy the links inside.

2. If the webmaster cannot make a 301 redirect and therefore has URL normalization issues, using absolute paths will help the link point to the selected URL version.

3. Even if the web page is moved, the links inside still point to the correct URL.

Disadvantages of absolute paths:

1. Unless the link is dynamically inserted, there is no way to test it on the test server. Because the link inside will point directly to the real domain name URL, not the URL in the test server.

2. Unless the link is dynamically inserted, it will be difficult to move the content page. Because the location of the content page changes, links on other pages may not change accordingly, and still point to the original hard-coded absolute path.

The above is the detailed content of What does the path of a file describe?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!