Relative path and absolute path

Source: Internet
Author: User
Tags file info

1. Relative path

Relative path: Refers to the path relationship to other files (or folders) caused by the path where the file resides.

    • Same directory file reference

"." -Represents the directory in which it is currently located.

Suppose: Now build a source file info.html, in info.html to refer to the index.html file as a hyperlink.

    • Index.html path is: c:\Inetpub\wwwroot\sites\jeri\index.html;
    • info.html file as a hyperlink. C:\Inetpub\wwwroot\sites\jeri\info.html.
 <!--  info.html  -->  <  a  href   >  Index.html</ a  >  <!--  omit "./"  -->  <  a  href  = "index.html"  >  index.htmla  >  
    • Indicates a parent directory

".. /"Indicates the directory that contains the source file at the top level of the directory,". /.. /"indicates the upper parent directory of the directory where the source file resides, and so on.

Suppose: Now build a source file info.html, in info.html to refer to the index.html file as a hyperlink.

    • Index.html path is: c:\Inetpub\wwwroot\sites\index.html;
    • info.html file as a hyperlink. C:\Inetpub\wwwroot\sites\Jeri\info.html.
<!---<= "... /index.html ">index.html</a>
    • Indicates a subordinate directory

Refer to the Subordinate directory file, directly write the path of the subordinate directory file.

Suppose: Now build a source file info.html, in info.html to refer to the index.html file as a hyperlink.

    • Index.html path is: c:\Inetpub\wwwroot\sites\Jeri\index.html;
    • info.html file as a hyperlink. C:\Inetpub\wwwroot\sites\info.html.
<!---< = "jeri/index.html" > index.html</a>
Advantages and Disadvantages

Advantages:

1. Easy to move content, can be moved throughout the directory.

2. The test method is more flexible, that is, I said that the local test is more convenient.

Disadvantages:

1. When the content page has changed position, the link is easily invalidated.

2. Easy to be copied by the People's Congress area.

2. Absolute path

Absolute path: Refers to the absolute position under the directory, directly to the target location.

    • Windows Operating System

Absolute path: Is the path from the beginning of the letter, shaped like C:\windows\system32\cmd.exe.

relative path: is the path starting from the current path, such as the current path is C:\windows, to describe the above path, just enter into System32\cmd.exe.
    • Linux operating system

The absolute path in the Linux system takes "/" as the starting example:/home/user1/abc.txt.

The relative path is: Home/user1/abc.txt.

Advantages and Disadvantages

Advantages:

1, to prevent the site is malicious plagiarism, the use of absolute path, if someone copied the collection of your content, the link will also point to your site. Some of the more lazy plagiarism, even the link inside copied the past.

2, if the webmaster can not do 301 turn, so there is the problem of Web site normalization, use absolute path to help link to the selected URL version.

3, even if the page is moved, the link is still pointing to the correct URL.

Disadvantages:

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

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

Relative path and absolute 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.