What's a subdomain?
You have a domain, like
silverthoughts.org. But you want to have a bunch of websites on it. Can you do that?
Yes! Subdomains can help. A subdomain is an extended name, based on your domain name, that acts like a separate website.
Take the site you're looking at now. It's at
learnweb.skilling.us. That's a subdomain. The name has three parts:
The domain is
skilling.us. I had to pay for that. Go to
skilling.us, and you see the main website for the Skilling project.
This website is a subproject, that's part of Skilling. I made the subdomain
learnweb, and put the files for this website there. It's a separate website from the one at
I didn't have to pay for the subdomain. I can make as many subdomains as I want, without spending a cent. Woohoo!
More, more, MORE!
There's another course website, on Excel VBA programming. That's at
So there are three separate sites:
skilling.us: the main project site
learnweb.skilling.us: this course
vba.skilling.us: a programming course
(Actually, there are more than that.)
They are all separate sites, not connected to each other. I only pay for
skilling.us, and can make as many sites as I want.
Subdomains have folders on your servers
Each subdomain has its own folder on your server. That's how the subdomains are kept separate.
Here are the folders for the subdomains above. The ~ is a Linux thing. It stands for my user account's root folder. On Windows, that's
The mapping from the domain (
skilling.us) to the folder
~/public_html was set up by the hosting company. I didn't change it. The subdomains, I created myself. I could have called the folders anything I wanted (e.g.,
anything-i-wanted), but I gave the folders the same names as their subdomains, to keep things easy for myself. Easy is good.
Wait. Can a dot be part of a folder's name?
Yes. In Windows, too. Give it a try. Create a new folder with a dot in its name.
OK, wait a mo... Hey! It worked!
You can have subdomains on your domain, too. For example, you can have one for your final project, and another for your other exercises. Keeping everything separate means that your files won't collide with each other.
Let's do it.
If you forget how to make a subdomain, come back here for a reminder.
Click the Subdomains icon on your cPanel home page. You'll see:
Type "final" in the Subdomain field. Hit tab. You'll see something like:
The Document Root is the folder where the files for your subdomain will be kept. We'll work on that in the next lesson.
Now make another domain. Call it "exercises". Note the document root. It will be something like
Password protect your
You should protect your
exercises subdomain. You'll be using it to submit exercises for this course.
In cPanel's file section, there's a Directory Privacy icon.
"Directory" is another word for "folder." You'll see both words used.
When someone tries to access a file in a private folder, they'll be asked for a username and password.
Remember, a subdomain is a reference to a folder on your server. If you protect the folder, you'll protect the subdomain.
Find the document root for your
exercises subdomain. It will be something like
exercises.yourdomain.com. Click the Edit button.
A form will show, that let's you protect the directory.
First, check the password protect box, and type a name for this security entry. Exercises is an easy one. Click Save.
Click Go Back to return to the configuration.
Then you need to make a user, who can access the folder. That's lower down the page.
Enter a username and password you can remember. Click save.
I had to mess around a bit before I got it working. You can look at the official documentation if you want.
When someone goes to the subdomain, they'll see something like this:
Remember, if you want someone to be able to see your work, you need to give them both the username and the password.
When you submit an exercise, you'll need to tell the grader what the username and password are.
Can I change the username and password?
Sure, no problem. Just go to the cPanel screen you just used, and change the info.
The only problem is that the grader might not have graded everything you submitted. Your submissions might have the old username and password. You can edit your submissions, though, those that haven't been graded yet, and add the new password.
What's this "Index of" thing?
I got this question from Anne-Abel:
I am not sure what I am doing wrong here. I created the folders and files per the course instructions, however they are not appearing properly. There's Index of /. I don't understand why it's changing to "index of". Appreciate your help.
A good question! This is what Anne-Abel saw:
This is perfectly normal. Most URLs contain a domain, a list of folders, and a file name, like this:
webexamples.skilling.us is the domain, linked to a server.
/pupperware/final/images is a list of folders, just like the C: drive on your PC, but on the server. Into the
pupperware folder, then into the
final subfolder inside
pupperware, then into
images. The last bit,
dogs.jpg, is the name of the file to show. A dog photo, in this case.
What happens when you leave off the folder and file name? Like this:
There is no folder or file. Every server is programmed to do something by default when this happens. What it does depends on how the server is programmed. The rules for Reclaim servers, unless you do something special, are:
- If there's a file called
index.html, show that.
- Otherwise, show a list of the files on the root (top) folder of the server.
That's what Anne-Abel saw. The server showed a list of files in her subdomain.
Try this one: http://webexamples.skilling.us.
If you look at the URL of this page, you won't see a file name. The URL ends in what looks like a folder name, but isn't. Instead, this server has programs that translate URLs into database lookup instructions. The text you're reading now isn't in a page anywhere. It's in a record in a database table.
When the server gets this URL, it looks up the text in the database, processes it in various ways, and sends back the results to your browser. This site explains how to write programs to do this sort of thing.
Thanks for the question, Anne-Abel. Questions like this help me improve the course.
Make a screen shot of your subdomains cPanel page, showing at least the subdomains
exercises (or whatever you called them). It might look something like this:
I have 32 subdomains (really!). Yours will be different.
- A subdomain adds something to the front of a domain, like
- Subdomains act as separate websites.
- Create as many as you want, from cPanel.
- cPanel lets you add encryption to your subdomains.
- cPanel lets you add usernames and passwords to your subdomains.
Let's see how you mess with files on your server.