educative.io

How are URLs that are not file locations handled by a server?

My understanding is that in general a URL represents a file location on a server, but for URLs not representing a file location - for example, a tinyURL - how are they handled when a server receives it? Is there some custom-defined URL handling API in part of the server application?


Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5649050225344512
Lesson: https://www.educative.io/collection/page/5668639101419520/5649050225344512/5668600916475904

Hi @AllenChou

I think there is a need to revise your understanding of URLs. Basically, A URL is nothing more than the address of a given unique resource on the Web. In theory, each valid URL points to a unique resource. Such resources can be an HTML page, a CSS document, an image, or even a file too (stored in DB on server-side) etc.

In practice, there are some exceptions that a URL pointing to a resource that no longer exists or that has moved. In that case, the server can through an appropriate status code (in this case, it is error:404) showing that the requested URL is not available. You may learn more about HTTP status codes and how they work.

@Usman_Younas thanks for your response! And thanks for clarifying that URL is an address pointing to a unique resource. But I still don’t understand how the address within a domain name is resolved. For instance, if such an address is given “https://www.abc.com/def/ghi”. Are the server-side responsible for implementing the logic that resolve “/def/ghi” and find the right resource before giving it to the users? How is this usually implemented?

In the tinyURL lesson, it’s mentioned that we can just use the key as URL, hence my question around how can the right resource be identified through that URL containing the key.

Hi @AllenChou, Now I got your point more clearly.

Without roaming around, let’s get to the point directly. The answer to your query is DNS, the Domain Name System.

The Domain Name System-DNS is the phonebook of the Internet. When users type domain names such as google.com or nytimes.com into web browsers, DNS is responsible for finding the correct IP address for those sites. Browsers then use those addresses to communicate with origin servers to access website information. This all happens thanks to DNS servers (machines dedicated to answering DNS queries).

So by definition, Domain name system, commonly known as DNS, is a system that averts the need to remember long IP addresses to visit a website by mapping easy-to-remember domain names to IP addresses.

So mean to say that there is no need to implement logic to resolve or find the right resource. It is already done by our DNS that is a part of the World Wide Web (WWW)

The remaining part of the question is, HOW the address within a domain name is resolved by DNS? Answering it here will go way long. An amazing course is available on the Educative platform with the title Web Application and Software Architecture 101. It would be best if you considered it. Read its Chapter # 6: Load Balancing. It has complete detail of how DNS works.

1 Like

Thanks! This is super-helpful!