Relative Addressing Using Paths

Started by chinmay.sahoo, 12-19-2015, 02:58:15

Previous topic - Next topic

chinmay.sahooTopic starter

Let us assume that our web browser is currently pointing to the webpage named index.php on the Erewhon Society website. We will call the directory in which the corresponding fi le is located, i.e. public_html, the current directory . (In this case this is also the home directory for the site.)


We will also assume that the page displayed has a link to another page on the same site, such as main.php in directory buildings. In the HTML for the displayed page the link from index.php to the fi le main.php will either take the form of an absolute link such as .

<a href="http://www.erewhonsoc.org/buildings/main.php"> Click here</a> or a relative link which simplifi es the address to just <a href="buildings/main.php"> Click here</a>

Having clicked on the link to main.php the current directory will now be buildings. If we want to place a link from there to annex.htm we can refer to it by the relative address "annex.htm". Any fi le name written like this is assumed to be in the current directory.

If instead we wished to link to fi le index.php back in directory public_html, we would refer to it as "../index.php". To link to the fi le student.php instead we would write the relative address as "../members/student.php".