Understanding Different Parts of a URL

Many people have a confusion understing URLs but most people thinks it's too late to learn. When I moved to web development I had no idea of internals as I just assumed that things magically worked out. I think it's better to learn the basics to get a better grip on terms and infrastructure for better understanding.

So let's see a URL


So let's see the differnet parts of this URL.
  • http:// is the URL scheme. Meanning how we will access the web page.

  • www.food.com Next is the host name. You can also have an IP address here but it's really hard for people and businesses to remember the IP address of a web page so there is a user friendly name. In this case food.com is the host name. When you make this request the DNS (Domain name server) will resolve (get information related to that domain ) the domain name and route you to the address of that domain.

  • 80 This is the port number. You might be thinking that this information is not really added in all the URLs that you usualy have so why do you need it here. This is the default port on which the server is listening to all the http requests. If you dont specify it the browser will internally add it. If you have any other port you can specify that externally and the browser will work accordingly.

  • local/street/food this is the path. indicating where you want to go on the web site. In this case I want to go to a local directory, the street and the food page.

  • #/carrot The last bit is the fragment. It's not always the name of the resource that we want to access or some html or any other page. In this case it means that on the food page go to the carrot part of the page (which could be by the end of the page) so when you open the page you will be automatically redirected to the end of the page.