The story so far
URLs are paths to files on servers. A domain points to a directory called the web root. Put files in the web root, and those files are on the web. Create directories in the web root, and you add pieces to URLs, like
Keeping projects separate
You're going to build a few separate projects in this course. It's critical to keep the files for each project separate. For example, a project about archery, and another about ships, could both have a file called
bow.jpg. Mix them up, and you'll have some strange web sites.
One way to keep projects separate is to have different domain names for each one, like
myshipproject.net. Give the projects different web roots, and there's no confusion.
https://myarcheryproject.org/photos/bow.jpg is a photo of a compound bow, and
https://myshipproject.net/photos/bow.jpg is a photo of the front of a ship.
The problem is, registering domains costs money. Each one is cheap, but a lot of them add up to a chunk of change.
Subdomains solve the problem. A subdomain is an extra part on the front of a domain. We can create as many subdomains as we like on the same domain. It won't cost us anything. Each subdomain will have its own web root.
To make a subdomain, log in to your web hosting account. Most hosts use cPanel, software that lets you manage your domain. In cPanel, click on the Subdomains link.
Now fill in a form to make a new subdomain. For example:
The subdomain will be
wickedfruit, on the domain
kieranmathieson.com. So, the subdomain's URL will be
Fill in the Document Root field as well. Document root is another name for web root, that is, the directory on the server where the files for
http://wickedfruit.kieranmathieson.com will be stored. I call mine
something is the name of the subdomain. Click
Create, and cPanel will make the subdomain.
So, if you put a file on the server in the directory
subdomains/wickedfruit, then anyone can get that file on the web. If you made a file called
socialistmarmoset.html, and put it in the directory
subdomains/wickedfruit, then anyone could get the file by pointing their browser at
A question. Say you wanted the URL of a file to be
http://wickedfruit.kieranmathieson.com/smug/monkeys/eating/pasta/yum.html. What would you do?
yum.html. Then I'd copy it to the directory
Look closely at the new URL:
Notice that the protocol is
https. Data moving between the server and a browser will not be encrypted.
If you want to encrypt, there's an extra step. Reclaim Hosting accounts come with Let's Encrypt, software that will make free SSL certificates for you. The certificates have the data needed for encryption.
Not all hosts offer this service.
On cPanel's home, click the Let's Encrypt icon:
Pick the subdomain you want to encrypt, and click
Issue on the next screen as well. Then you can access your subdomain with
- Subdomains separate files for different projects.
- You can have as many subdomains as you like.
- Use cPanel to make subdomains. You give each one a web root, like
subdomains/valuemice. Files for the subdomain will come from that directory.
- You can encrypt the traffic, if you want.