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.
#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 pathrefers 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
Relative pathrefers 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 文件夹里的一个文件:
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!