URLs

Cute mammal

Log in

If you're a student, please log in, so you can get the most from this page.

You type a URL into a browser. Like https://laughingatoms.com, or http://webappexamples.skilling.us/dogs/renata.html. What is that URL thing?

URLs are addresses

Every file on the Web has a URL (uniform resource locator). Whether it's an HTML file, a photo file, whatever, it has a URL. A file's URL is its unique address on the Web.

Try this URL: http://webappexamples.skilling.us/dogs/renata.html

The URL has three parts:

  • A protocol: http
  • A domain: webappexamples.skilling.us. (It's actually a subdomain. More on that later.)
  • The path: /dogs/renata.html

The protocol

The protocol is the set of rules for how clients (like your browser) and servers talk to each other. When your browser wants a file, it sends the word GET to the server. When a server receives the word GET, it knows that's a request for a file.

Why the word GET, and not SENDME, or BEKOMMEN? No good reason, really. A British dude chose the word GET years ago. As long as computers agree on what word to use, it doesn't matter much what the word is.

The person who chose GET named the protocol HTTP, which stands for... you can look it up, if you care.

Here's the URL again:

http://webappexamples.skilling.us/dogs/renata.html

It says "http", but there's also "https". The S on the end means "secure." The requests from your browser to the server are encrypted, like secret spy stuff. The responses from the server to your browser are encrypted as well.

These days, you should usually use https. There isn't a good reason not to, as far as I know.

The domain

The URL is:

http://webappexamples.skilling.us/dogs/renata.html

webappexamples.skilling.us is the domain. It's like the name of a web server.

​Servers and domains

​Servers and domains

To put something on the web, you need two things:

  • A server to put the files on.
  • A name for that server, that is, a domain.

When you bought hosting from Reclaim, you got two things:

  • Space on a server to put files.
  • A name that points to your server space.

Your domain name is actually a placeholder for an IP address. More later.

The path

The URL again:

http://webappexamples.skilling.us/dogs/renata.html

The first bit, http://webappexamples.skilling.us identifies a server.

The last bit, /dogs/renata.html, is the path. It's the location of a file on the server.

Think about your computer, the one you're using to read this text. If you're using a phone, or tablet, that's a computer. A small one, but still a computer.

Your computer has thousands of files. They're grouped into folders. Windows, Mac OS, Linux, Android... all of them put files in folders.

("Folder" and "directory" mean the same thing.)

/dogs/renata.html tells the server to go into the folder dogs, and look for a file called renata.html.

(OK, it can be set up differently, but go with it for now.)

Here's a drawing of the situation.

URL as path

The URL is:

http://webappexamples.skilling.us/dogs/renata.html

webexamples.skilling.us is a server. Its disk drive has a folder called dogs. In that folder, there's a file called renata.html.

Adela
Adela

OK. Let's say I wanted to make a webpage with the URL of elephant.com/parts/trunk.html. On my PC, I make a file called trunk.html. Then I go to the server elephant.com, make a folder called parts, and upload trunk.html. Is that right?

Yes! You got it.

Folders, file lists, and index.html

Reflect

The URL is http://webappexamples.skilling.us/dogs/renata.html. Drop the last part, and try http://webappexamples.skilling.us/dogs. What so you see?

If you were logged in as a student, the lesson would pause here, and you'd be asked to type in a response. If you want to try that out, ask for an account on this site.
Ethan
Ethan

Are those the files on the dogs folder on the server?

Aye, that's right!

Georgina
Georgina

Wait, so drop the dogs bit, just use http://webappexamples.skilling.us, what do you get?

Try it: http://webappexamples.skilling.us.

Top level

They're the files and folders on the server.

The / in "Index of /" shows you at the root of the server. The top level.

Adela
Adela

OK, but when I go to https://www.amazon.com/, I don't see a list of files, I see a webpage.

Ooo, good point! Web servers are set up so that if they get a URL without a file name, like https://www.amazon.com they use some default file names, like index.html, and index.php. If a file with a default name isn't there, they show the file list, like this:

Top level

Let's take Moodle. It's written in PHP, the same language you'll learn. Here are two URLs:

Reflect

Here are two URLs to try:

What can you tell me about the two pages you see?

If you were logged in as a student, the lesson would pause here, and you'd be asked to type in a response. If you want to try that out, ask for an account on this site.
Ray
Ray

They look the same.

They are the same. When you use https://moodle.org, the server at that domain says to itself:

Self, there's no file name in the web root. I'll look at my list of default names... Oh, there's index.php in the web root. I'll use that.

In fact, if you look inside the Moodle file list, you'll see that file:

Moodle files

Put it all together

Someone clicks on a link to:

http://webappexamples.skilling.us/dogs/renata.html

A conversation starts.

Web browser: Hey, internet! I wanna send a message to webappexamples.skilling.us.

Internet: OK. What language you wanna talk in? Chinese? Swedish?

Browser: Nah, I wanna talk HTTPS.

Internet: OK. What you wanna say?

Browser: GET /dogs/renata.html

Internet: OK, I'll pass it on.

Internet: Hey, webappexamples.skilling.us!

Server: What do you want?

Internet: Some browser said: "GET /dogs/renata.html"

Server: OK, wait a mo... Here: (sends contents of the file renata.html)

Internet: Yo, browser!

Browser: Huh?

Internet: webappexamples.skilling.us says this: (sends what it receives from the server)

The browser renders the HTML it got from the internet. (Renders means interpret-and-show. More later.)

Servers have numbers, not names

There's a wrinkle you should know about. On the internet, computers have numbers, not names. There is no server called webappexamples.skilling.us.

Instead, there's a table, matching names and numbers.

The numbers are IP addresses. Your Reclaim server has one. When you bought a domain name from Reclaim, they made an entry in the internet's directory, linking your name to the IP address of your server. You can find the IP address in cPanel. You'll learn about cPanel soon.

IP in cPanel

Summary

A URL is the address of a file on the internet (more or less). It has three parts:

  • Protocol (http or https)
  • Domain
  • Path

Servers on the internet have numbers, called IP addresses. A domain name is an entry in a table, linking names and IP addresses.