Web Design
Mobile Internet
Brand Design
Innovative
News
Encyclopedias

What are the absolute path and relative path of website hyperlink

Date:2016-07-22 Source: Shangpin China Type: website encyclopedia
Word Size: small   medium   big

Understanding the file path from the document that is the starting point of the link to the document that is the target of the link is critical to creating the link. each Enterprise website construction Web pages have a unique address, called a Uniform Resource Locator (URL). However, when creating a local link (that is, a link from a document to another document on the same site), you usually do not specify the full URL of the document that is the target of the link, but specify a relative path starting from the current document or the root folder of the site. There are three types of link paths.

1. Absolute path

Provide the full URL of the linked document, and include the protocol used (for example, for Web pages, usually //), such as //ihucc.com/ , as shown in Figure 2-38.
 Create absolute path

You must use an absolute path to link to documents on other servers. Absolute path links can also be used for local links (that is, links to documents in the same site), but this is not recommended, because once this site is moved to another domain, all local absolute path links will be broken. By using relative paths for local links, you can also increase flexibility when you need to move files within the site.

Note: When inserting an image (not a link), you can use the absolute path to the image on the remote server (an image that is not available on the local hard drive).

2. Document relative path

For an overall Web site, the document relative path is usually the most appropriate path. The document relative path can also be used to link to the web page files in other folders by using the folder hierarchy to specify the path from the current document to the linked document. The basic idea of document relative path is to omit the absolute path part that is the same for the current document and the linked document, and only provide different path parts. Assume that the structure of a site is shown in Figure 2-39. To link from contents.html to hours.html (two files are in the same folder), you can use the relative path hours.html To link to tips.html (in the resources subfolder), you can use the relative path resources/tips.html. Every occurrence of/ A slash means to move down one level in the folder hierarchy.
 Site Structure
To link to index.html (one level above contents.html in the parent folder), you can use the relative path/ index.html。 Each occurrence of a two/slash indicates that the folder is moved up one level in the folder hierarchy. To link to catalog.html (located in other subfolders of the parent folder), use the relative path/ Produc/catalog.html。 Where/ Move up to the parent folder and products/down to the products subfolder.

At this time, when the user moves the entire site folder (such as My_site) to another disk (such as moving from disk E to disk F), all files in the folder remain the same relative path to each other. At this time, there is no need to update the document relative links between these files. However, when you move a single file that contains or is targeted by document relative links, you must update those links.

3. Site root directory relative path

The relative path of the site root directory refers to the path from the root folder of the site to the document. If you are dealing with a large Web site that uses multiple servers, or if you are using a server that hosts multiple sites, you may need to use these paths. However, if you are not familiar with this type of path, it is better to stick to the document relative path.

The relative path of the site root directory starts with a forward slash, which represents the site root folder. For example,/supportltips.html is the site root directory relative path of the file (tips. html), which is located in the site root folder
In the support subfolder of the.

If you need to frequently move HTML files between different folders on your Web site, the relative path of the site root directory is usually the best way to specify links. When you move a document that contains relative links to the site root directory, you do not need to change these links.

However, if you move or rename the documents pointed to by the relative links of the site root directory, you must update these links even if the relative paths between the documents have not changed. For example, if you move a folder, you must update all site root relative links to files in the folder.


Please contact our consultant

+86 10-60259772

Please provide your contact number. The project manager of shangpin China will contact you as soon as possible.