Understanding Web Addresses and Links

Written By ubakara Samy

Hello,

Having problems with links on your web-site’s?

You need to understand the web addressing and links.

If you have a problem while shifting your website from one workspace or server to another workspace or server.

Check out your web-addressing type.

Types of web addressing or routings

1) Absolute Links

2) Relative Links

3) Root-relative Links

Example consider that you have a website with four pages

index.php, about.php, services.php and contact.php

Absolute Links

<a href=”http://example.com/pages/about.php”>About</a>

This is a path for about page from a website example.com

If you want to make changes to this site you will move this site to your local machine.

but the routes will not work on your local machine.

you need to change routes every time you move the site from one place to another place with Absolute Links.

Relative Links

<a href=”../index.php”>About</a>

This is the example of Relative Link. consider you are at about page

if you use ../ once the route will move back one folder.

the same way if you use this two times ../../ will move back to two folders.

in this way of routing your site, you will not get errors while moving your site from local to server and server to local.

Root-Relative Links

<a href=”/about.php”>About</a>

This is an example of root-relative links.

This is a root based link / is redirects to a root folder.

In this case, we will provide an exact path for the link from the root directory.

Conclusion

I suggest you use Root-Relative Links because if you use relative links at the time of moving directory from one place to another inside the root folder you will be confused routing with Relative-Links

Post Your questions on your comments in the below section.

Happy Codding 🙂

 

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*
*