URL paths

Hi there.

whats the difference between root path and base url ?

I have a website say test.com in there is the main index.php file

In this directory i have a subfolder called sample also with an index.php file

on all the other pages will be a link back to the homepage.

<a href="index.php"> Home</a>

if i wanted to link back to the folder index.php file and not the root index.php file is this the correct link ?

<a href="<? BASE_URL;?>index.php"><h2>Home</h2></a>

The root path refers to a physical directory on a server’s filesystem where the website’s files reside.
The base URL refers to the prefix URL that is used for all relative web URLs within that website.

You don’t have to have the root path be the same as your URL. An example →

require_once __DIR__ . '/../bonbonconfig/bonbonConfig.php';

That is where the physical directory for the configuration file is and obviously you wouldn’t have the base URL pointing to it. Though in general they basically mean the same thing for web development, but it is important to know the difference when it is needed.

Sponsor our Newsletter | Privacy Policy | Terms of Service