Create a subdomain that points to a directory

Please note: This functionality is not available on Economy or Basic Hosting plans. This functionality is only available on our 50GB Hosting plans and above. Subdomains are not currently supported on our Apache and IIS7 server environments due to server aliases not being available for configuration at the moment. The below steps will redirect visitors that visit your subdomain to a directory of the same name located inside your hosting account. e.g. Visitors to http://subdomain.domain.tld/ will see files located in http://www.domain.tld/subdomain/

Step 1. Create the CNAME

Create the CNAME for your subdomain in  Zone Manager and point it towards your host site. To do this do the following.

  1. Log into your Account.
  2. Locate the domain name via Manage Domains (under the Domains and Hosting menu).
  3. Click on the Domain name to access the domain name level.
  4. Click on Zone Manager.
  5. Scroll down to where the page states To add a record to this zone click on a type, and click on the CNAME link.
  6. In the name field, enter the first part of your subdomain. eg. if the subdomain will be http://subdomain.domain.tld then simply enter ‘subdomain’ in the name field.
  7. Leave the ttl field as is.
  8. In the host field, enter your primary domain name. eg. domain.tld

Step 2. Create a server alias

Create a server alias for the web server to recognise the new host as a valid one. To do this do the following.

  1. Log into your Account.
  2. Locate the domain name via Manage Domains (under the Domains and Hosting menu).
  3. Click on the Domain name to access the domain name level.
  4. Click on Web Hosting.
  5. Scroll down to the Webserver Options heading.
  6. Click the link which states Click to modify your server aliases.
  7. In the server alias field, enter the name of your subdomain. eg. if the subdomain will be http://subdomain.domain.tld then simply enter ‘subdomain’ in the server alias field.

Step 3. Add a rewrite rule

Add a rewrite rule for the sever to redirect a subdomain request, to a subdirectory of the same name:

For Litespeed:

Add the following in the .htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.* [NC]
RewriteRule .* http://www.domain.tld/subdomain/ [L]

For Zeus:

  1. Log into your Account.
  2. Locate the domain name via Manage Domains (under the Domains and Hosting menu).
  3. Click on the Domain name to access the domain name level.
  4. Click on Web Hosting.
  5. Copy and paste the below rewrite code into the Request Rewrite Support field on the Web Hosting page.
  6. Select the radio button above the Request Rewrite Support field which states Enabled.
  7. Click on the Change button underneath the Request Rewrite Support field.

Below is the Zeus rewrite rule which will redirect visitors to http://subdomain.domain.tld/ towards the files located in http://www.domain.tld/subdomain/

RULE_1_START:
insensitive match IN:Host into % with ^www.domain.tld
if  matched then goto END
RULE_1_END:

RULE_2_START:
insensitive  match IN:Host into % with ^(.*).domain.tld
if matched then match URL  into $ with ^/(.*)
if not matched then goto RULE_2_END
set URL =  /%1/$1
RULE_2_END:

where domain.tld = your domain name. This rule basically tells the server the following: Rule 1 – If the host entered is just www.domain.tld – do nothing Rule 2 – If the host entered is ANYTHING-ELSE.domain.tld – go to domain.tld/ANYTHING-ELSE This means that any one of your subdomains will go to it’s corresponding subdirectory. You will need to have created this subdirectory in your hosting account and have files in it, preferably an index.html or index.php file. Please allow time for CNAME propagation. (Note: To activate this feature, the domain name package must be on Business+ hosting package or higher)