Parts of URL

We see so many URLs everyday, but do we know what are the parts of an URL, what does each part means? In this post I will discuss the various parts of the URL.

An URL may consists of as many as 6 parts. The different parts of the URL are:


Some people refer to the parts as:


Just to easily remember the different parts, I normally refer the URL as


Now lets see what each part means.

Part Meaning Required
scheme or protocol Internet protocol to be followed. e.g. http, https, ftp, mailto, etc. This defines the syntax of the URL. Yes
domain or hostname This is the destination location for the URL. It can be a hostname or ipaddress. Yes
port The port to be used to connect to the location. No
path or pathname This is typically a file or location on the web server. No
query_string or search This is the data to be passed to software running on the server. No
fragment_id or hash This specifies a part or a position within the overall resource or document No

Lets see a few example URLs to understand what are the different paths of the URL.

Example 1:
This URL consists of only 2 parts. They are:

protocol http

Example 2:
In this URL the different parts are:

protocol http
port 80
path example.php
query_string ?x=1&y=2
hash #results

Example 3:
In this URL the different parts are:

protocol http
port 80
path example.php
query_string ?x=1&y=2
hash #results

Lets analyse the example 3 in more detail
The URL is

In this URL we will breakdown the URL further

  • The protocol is http
  • The domain is
  • The subdomain is www
  • The top-level domain or TLD id in. The in domain is also referred to as a country-code top-level domain or ccTLD. For, the TLD would be com.
  • The port is 80
  • The path is /example.php
  • The query string is ?x=1&y=2#results. This query string can be further divided into parameter. URLs can have lots parameters. Parameters start with a question mark (?) and are separated with an ampersand (&). First parameter is x with value 1.
  • The hash is #results

Related posts:

  1. Get various parts of URL using JavaScript
  2. Protocol relative URLs
  3. more .htaccess tips
  4. PHP 5.5 Password Hashing API

1 thought on “Parts of URL”

Leave a Reply