Newby Coder header banner

Programming Absolute Path

What is Absolute Path in Programming

The absolute path is the path or location of a file or directory from the root directory of an operating system

It is also referred to as full path

For example, if a file wallpaper.jpg is downloaded to Downloads folder

Then its absolute path in Windows is something like

C:\Users\John\Downloads\wallpaper.jpg

and in Linux its something like

/home/john/Downloads/wallpaper.jpg

Alternatively, relative path is the path or location which is relative to a directory

Considering wallpaper.jpg in Downloads folder, if the user opens a Terminal and changes theworking directory to Downloads folder then the user can access the file with its path relative to theworking directory which in this case is the name of the file itself

cd /home/john/Downloads/wallpaper.jpg
mv wallpaper.jpg ~/Pictures/

Here, it moves wallpaper.jpg(which is its relative path) to ~/Pictures/

What is an Absolute Path of URL

An absolute URL points to a very specific location on the Web and contains the necessary information to locate a resource (such as a web page or a download link)

Absolute URLs must be used to link to other websites that are not located on the same domain such as an url of an Youtube page from a Facebook page

Alternatively, a relative URL is relative to the domain of an Url

Consider the absolute URL

[ncw-wd]/sample/file/a_picture.jpg"

It's relative path is the path after its domain name

/sample/file/a_picture.jpg

In such cases, a web browser adds the relative path to the current url to get its absolute path and forward the user

But if such a link is added to the Html of a page which has a path after the domain name

Then the relative path has to navigate to the parent directory (using .. two dots)

For example the relative url of an image [[ncw-wd]] from url [[ncw-wd]]/sample/redirect/sample_redirect

is
../../icon.jpg