CS · EN

Webhosting - Subdomains

This article covers subdomain setup on Webhosting. Typically, this is a subdomain that you run on the same service as the main domain. To create a subdomain in DNS (for example for a website with another provider), follow the instructions in the article DNS – Subdomains.

In this article you will learn:


Subdomains on Webhosting

On Webhosting, under the main domain name, you can create any number of subdomains with separate websites for this domain (and possibly for aliases). Check that you meet the following conditions:

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

If the domain does not use our DNS, check with the DNS server provider you actually use.


Creating a subdomain via FTP

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

You can find instructions for managing files via FTP in the article Webhosting – File Management.

To create a subdomain via FTP, follow these steps:

  1. Log in to FTP, for example using the WebFTP ⧉ client (Manual).
  2. Go to the www/subdom or www/domains folder.
  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 www/subdom folder 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 domena.tld webhosting you create the obchod.domena.tld subdomain by adding a folder named obchod to the www/subdom folder.

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 full domain name including the domain extension. For example, on the domena.tld webhosting you create the obchod.domena.tld subdomain by adding a folder named obchod.domena.tld to the www/domains folder.

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 with the application installer

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

To install an application on a subdomain, in the first step of the installation itself enter the subdomain name between http:// and the domain name. For example, on the domena.tld webhosting you create the obchod.domena.tld subdomain by entering the word obchod into the field between http:// and  domena.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

Full HTTPS activation (certificate issuance and propagation) usually takes up to 90 minutes.

Enable HTTPS on Webhosting according to the instructions Webhosting – Quick HTTPS Setup. Then follow the instructions Webhosting – Manual HTTPS Setup to enter domain and subdomain management.

Add subdomains to the certificate using this procedure:

  1. Click the add domains button.
  2. At the bottom of the form, enter 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 addition of subdomains to the Webhosting Let’s Encrypt certificate
Sample addition of subdomains to the Webhosting Let’s Encrypt certificate

If no error occurs, HTTPS will be active for 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, Internal Server Error 500 is displayed.

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

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

Cannot create the subdomain folder with the installer

Problem: The application installer reports the error: The target directory /www/domains/sub.domena.tld is not empty.

Cause: The installer detected an existing installation, or remnants of it 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 CMS is not compatible with the default WEDOS .htaccess, so subdomains do not work.

Cause: CMSs placed in the www folder can 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 www/domains/domena.tld folder, where domena.tld is the domain of the main website. Then restore the default .htaccess.

Non-functioning www subdomain

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

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

Solution: Redirect the www subdomain to the fully secured non-www subdomain. If you use our default .htaccess file, add this code immediately below RewriteEngine On:

# 301 redirect www.sub.domena.tld -> sub.domena.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 will be displayed?

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

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

The default .htaccess file is located only in the www folder. In subdomain folders, you can have any .htaccess files. If there is a conflict between .htaccess files or a forbidden command is entered, Error 500 will occur.

Where will a visitor who enters a non-existent subdomain be taken?

If the subdomain does not exist in either the subdom or domains folder, the content from the www folder will be displayed.