vangelis
By:
vangelis

How can I add a subdomain to my website?

February 17, 2016 2k views
DNS VPN

I want to have artwork.mywebsite.com instead of mywebsite.com/artwork.
How can I make it happen?

I own a Ubuntu 14.04 x64 droplet.

My droplet has everything from the "Initial Server Setup with Ubuntu 14.04" tutorial.

2 Answers

Hey there,

You would create a virtual host for the artwork.mywebsite.com domain pointing to a different folder than your mywebsite.com's document root. This tutorial reviews setting up virtual hosts (multiple websites) for Apache running on Ubuntu.

You would also need to create an A record in your DNS zone pointing artwork to your IP address.

Happy coding,

Jon Schwenn
Platform Support Specialist
DigitalOcean

by Justin Ellingwood
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.
  • Now am in the stage where I have artwork.mywebsite.com up and running and I can access it in a web browser with no problem. However, I did not do any A record thingy. Do I need to do it, if so how?

    • There are a few reasons why it may work without creating an A record:

      1. You hardcoded artwork.mywebsite.com in your hosts file
      2. You have a wildcard CNAME or A record

      As long as it's working regardless of the computer/internet connection, I would leave it be :)

  • Hi, there!

    Do you mean that for every subdomain like artwork.mywebsite.com or forum.mywebsite.com, I need to create a new virtual host every time? Thanks in advance!

Have another answer? Share your knowledge.