‹ Articles

How to Create a Subdomain

Using subdomains with ServerPilot is exactly the same as using any other domain name.

If you want your users to see a different website when visiting a subdomain, such as being taken to your online store when visiting "shop.example.com," you should create a new app and assign the subdomain as one of the new app's domain names.

If the subdomain is simply an alias for an existing website, such as "www," go to the app you already created in ServerPilot and add the subdomain to the app's list of domain names.

You can add and remove domain names from your apps at any time. Here's how:

How to Add and Remove Domains

Subdomain Example

Imagine you have two apps/sites to run on your server. One of them is your main website, and you need it to be available as both example.com and www.example.com. Your other app is your WordPress blog that needs to be available as blog.example.com.

Here's how you'd set this up through ServerPilot:

Step 1: Create an app for your main website.

In ServerPilot, go to the Apps page and click Create App. Give this app a name like main. Next, also in ServerPilot, add both example.com and www.example.com as this app's domains.

Step 2: Create an app for your blog.

Now, repeat what you did in Step 1, only for the blog app. In ServerPilot, go to the Apps page and click Create App. Give this app a name like blog. Now add blog.example.com as this app's domain name.

Step 3: Upload your files.

After you've completed Steps 1 and 2, you'll have two separate web root directories (the term for where your web files live) on your server - one for each app. These directories will be located here (though your system user will likely be different):


As you've probably guessed, you would upload your main files to /srv/users/serverpilot/apps/main/public and your blog files to /srv/users/serverpilot/apps/blog/public.

Step 4: Point DNS to your server's IP address.

Now, go to where you manage DNS for your domain. In this example, it would be where we manage DNS for example.com. You should create separate A Records pointing to your server's IP address for each of the following:

  • example.com
  • www.example.com
  • blog.example.com

Once your DNS changes have propagated (this can take a few minutes to some hours, depending how your domain's DNS is configured - we have more information about DNS propagation here: What is DNS Propagation,) your apps will be accessible by the domain names you've assigned to them.

Optional Step 5: Adding more domain names.

You can add and remove domain names from your app at any time. Imagine you decide you want your blog to also be accessible as www.blog.example.com. Just log in to ServerPilot, go to your blog app, and add the domain name www.blog.example.com. Don't forget to also go to your DNS provider and created an A Record for this name.

Last updated: August 14, 2019

Still Have Questions?

Don't hesitate to contact us if you can't find the answers to your questions.