Uniform Resource Locator (URL) is the global address of documents and other resources on the World Wide Web. On the web, each web page has the URL which is in the address bar of browser as illustrated
Some key parts to the URL are the protocol, the domain name and the file path.
- Protocol – It is usually, this is “http”, followed by “://”, though it can be “https”, “ftp”, or other things. It is the method to get the information from a server. Most web pages use the Hypertext Transfer Protocol (HTTP). It is the method how the information is given.
- Hostname or Domain Name This is usually everything after “://” but before the next “/”, if there is one. It is usually the domain name. A hostname like “www.example.com” can be further broken down into the top-level domain (“com”), the domain name (“example.com”), and the sub domain (“www”). It is also called the host address and can also be a number called an IP address. All computers on Internet have an IP address which is a set of 12 digits separated by a period. A domain name is converted into IP address for getting the web page by a domain name server (DNS), which has directory of domain names and the corresponding IP addresses.
- File Path – It is anything that appears after the “/” or after the hostname, but before a possible “?”. An example would be “games/images/display.html”. It can be quite long. It can have a filename (“display.html” in the previous example), or just be one or more directories (“games/images/” in that example). This denotes what file to display at that site. It always begins with a forward slash character and may consist of one or more directory names. It usually correspond to the directory structure of the web site
Every file on the Web has its URL to be accessed by web server and if a file has no URL, the web server will then
- Look for a default file and return that like index.html.
- Show a error message saying that the page cannot be found or a 404 message.