Knowledge Base›Webhosting›Subdomains

Webhosting – Subdomains

On this pageSubdomains on WebhostingCreating a subdomain via FTPCreating a subdomain using the application installerSetting up HTTPS on a subdomainCommon problemsFrequently Asked Questions

This article covers setting up a subdomain on Webhosting. This is typically a subdomain that you run on the same service as the main domain. To create a subdomain in DNS (for example, for a website hosted by another provider), follow the guide DNS – Subdomains.

In this article you will learn:


Subdomains on Webhosting

On Webhosting named after the main domain, you can create any number of subdomains with separate websites for this domain (and, if applicable, its aliases). Make sure that you meet the following conditions:

Sample DNS records with the main domain and all subdomains pointing to the same Webhosting
Sample DNS records with the main domain and all subdomains pointing to the same Webhosting

If the domain does not use our DNS, perform the check at the provider of the DNS servers you actually use.


Creating a subdomain via FTP

You can create subdomain websites via FTP in the folder www/domains, or www/subdom. This choice affects how subdomains behave with respect to aliases. If you do not use aliases, we recommend using the folder www/domains.

A guide to managing files via FTP can be found in the article Webhosting – File Management.

To create a subdomain via FTP, follow these steps:

  1. Log in to FTP, for example using the client WebFTP ⧉ (Manual).
  2. Enter the folder www/subdom or www/domains.
  3. Create a new directory according to the instructions for the given folder.
  4. Upload the website files, including index.html or index.php.

Subdomains in www/subdom

Websites in the folder www/subdom are shared subdomains of all alias domains. You create a new subdomain here by creating a directory named after the subdomain itself, without the domain extension. For example, on the Webhosting domain.tld you create the subdomain shop.domain.tld by adding a folder named shop to the folder www/subdom.

Sample subdomain obchod.wds-test.cz created in the subdom directory
Sample subdomain obchod.wds-test.cz created in the subdom directory

Subdomains in www/domains

Websites in the domains folder are displayed exclusively on the given domain or subdomain (with or without www).

You create a new subdomain here by creating a directory with the complete domain name, including the domain extension. For example, on the Webhosting domain.tld you create the subdomain shop.domain.tld by adding a folder named shop.domain.tld to the folder www/domains.

Sample subdomain obchod.wds-test.cz created in the www/domains directory
Sample subdomain obchod.wds-test.cz created in the www/domains directory

Creating a subdomain using the application installer

If you use the application installerto build your website, you do not need to create the subdomain folder manually on FTP. Just make sure that if the following folder exists in www/domains , it is empty (otherwise the installer will return an error).

To install an application on a subdomain, simply enter the subdomain name in the first step of the installation itself, between the http:// and the domain name. For example, on the Webhosting domain.tld you create the subdomain shop.domain.tld by entering the word shop in the field between http:// and  domain.tld.

Sample subdomain obchod.wds-test.cz created using the application installer
Sample subdomain obchod.wds-test.cz created using the application installer

Setting up HTTPS on a subdomain

Fully enabling HTTPS (activating and propagating the certificate) usually takes up to 90 minutes.

You activate HTTPS on Webhosting by following the guide Webhosting – Quick HTTPS Setup. By following the guide Webhosting – Manual HTTPS Setup you then enter the management of domains and subdomains.

Add subdomains to the certificate as follows:

  1. Click the Add Domains.
  2. In the lower part of the form, write a list of subdomains (without the main domain name) separated by commas.
  3. Confirm the addition with the Add Domains button at the bottom of the form.
Sample of adding subdomains to the Webhosting Let’s Encrypt certificate
Sample of adding subdomains to the Webhosting Let’s Encrypt certificate

If no error occurs, HTTPS will be active on the subdomains within 1.5 hours.


Common problems

Common problems with managing subdomains on Webhosting include:

Error 500 on a subdomain

Problem: After creating a subdomain in both the domains and subdom folders, the following is displayed: Error 500 Internal Server Error.

Cause: You must create the subdomain either in the domains folder or in subdom, not in both.

Solution: Delete one of the conflicting folders in domains/subdom.

The subdomain folder cannot be created by the installer

Problem: The application installer reports an error: Target directory /www/domains/sub.domain.tld is not empty.

Cause: The installer detected an existing installation, or its remnants, on FTP.

Solution: Log in to FTP and delete the entire subdomain folder in the domains folder. Do not create a new one.

Incompatible .htaccess of the main website

Problem: The .htaccess file of my content management system is not compatible with the default WEDOS .htaccess, so subdomains do not work.

Cause: Content management systems located in the www folder may overwrite the .htaccess file with their own rules, or their rules are not compatible with those in the default .htaccess.

Solution: If you have a problematic main website in the www folder, move it to the folder www/domains/domain.tld, where domain.tld is the domain of the main website. Then restore the default .htaccess.

Non-working subdomain with www

Problem: We have added a certificate on the subdomain, including the version with www. The subdomain itself works, but the version with www does not. The certificate is active for both.

Cause: This problem is common for domains using WEDOS.protection. The certificate for a fourth-level domain (of the type www.sub.domain.tld) is located on the Webhosting but not on the proxy server, so the connection is evaluated as insecure.

Solution: Redirect the subdomain with www to the fully secured subdomain without www. If you are using our default .htaccess file, add immediately below RewriteEngine On this code:

# 301 redirect www.sub.domain.tld -> sub.domain.tld
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+\.[^.]+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

Frequently Asked Questions

If I create a subdomain in both domains and subdom, which one is displayed?

An Error 500will occur. Choose one location for your subdomain and delete the duplicate subdomain.

What should the default .htaccess file in a subdomain folder look like?

The default .htaccess file is located only in the www folder. In subdomain folders you can have any .htaccess files you like. If there is a conflict between .htaccess files or a prohibited directive is entered, an Error 500.

Where does a visitor end up who enters a non-existent subdomain?

If the subdomain does not exist in either the subdom or domains folder, the content of the www folder is displayed.

Was this article helpful?

Your feedback helps us improve our articles.

Your message goes to the documentation team, who do not reply to it. If you need help, contact us using the contact form. Do not include passwords or personal data.

Didn't find what you were looking for?

Ask other customers on the Help community website.