How to Add a Domain, Subdomain and Domain Pointer in DirectAdmin

Add a second domain, a subdomain or a domain pointer in DirectAdmin, see where each one lives on disk, and choose between an alias and a redirect pointer.

Published
Reading time
4 min

A DirectAdmin account starts with one domain, and most accounts end up with more: a second site, a blog. or shop. subdomain, or an old domain that should simply show the same content. DirectAdmin has a different page for each of those three cases, and each puts files in a different place. This guide covers all three, for a user with an account whose package allows them.

Where domains live on disk

Every domain in an account has its own directory tree under the account's home:

/home/<user>/domains/example.com/
    public_html/      the web root, what visitors see
    private_html/     historically the HTTPS root
    logs/             Apache access and error logs
    stats/            web statistics

public_html is where index.php goes. private_html is a leftover from the days when the HTTPS site could be different from the HTTP one; on any current install it is a symlink to public_html, so both protocols serve the same files. If you ever find a domain serving different content over HTTPS, check whether private_html has become a real directory, and use the Use a symbolic link from private_html to public_html setting on the domain in Domain Setup to put it back.

The Apache error log for a domain is also mirrored at /var/log/httpd/domains/example.com.error.log on AlmaLinux and Rocky, or under /var/log/apache2/domains/ on Debian and Ubuntu, which is where the admin looks.

Add a second domain

User Level → Account Manager → Domain Setup → Add New. Type the domain name, and set whether it may use its own share of the account's bandwidth and disk (the default is to share the account's limits), and whether SSL, CGI and PHP are on for it. Save, and DirectAdmin creates the directory tree above, a DNS zone in /var/named/example.com.db, the mail domain and the Apache virtual host. It is live once the task queue runs, usually within the minute.

Two things to check on the DNS side. If this server runs the domain's nameservers, the zone it just created is complete and you only need to point the domain at those nameservers at the registrar. If DNS is elsewhere, at Cloudflare or the registrar, add an A record there for example.com and www pointing at the account's IP, and the zone on this server is ignored.

A domain can only exist once on a server. If another account already has it, even as a pointer, the add fails with a message saying so, and the admin has to remove it from the other account first. Once the domain is added, the SSL page issues its certificate.

Add a subdomain

Account Manager → Subdomain Management, pick the parent domain, type the subdomain name and add. The document root defaults to a directory inside the parent's web root:

/home/<user>/domains/example.com/public_html/blog/

That works, but it has a side effect: example.com/blog/ and blog.example.com serve the same files, and if the parent site is WordPress its .htaccess rules can catch requests meant for the subdomain. Recent versions let you set a different document root when creating the subdomain; putting it outside the parent's public_html avoids the overlap.

DirectAdmin adds the subdomain's A record to the zone automatically. Subdomains do not get their own mail; mail@blog.example.com is not something the panel creates.

Add a domain pointer

Account Manager → Domain Pointers. A pointer is a second name for an existing domain, and the form offers two kinds.

An alias pointer serves the same site under both names. example.co.uk shows exactly what example.com shows, with the address unchanged in the browser, and mail to @example.co.uk is delivered to the same mailboxes. Aliases are added to the domain's Let's Encrypt certificate automatically the next time it is issued, so both names work over HTTPS.

A redirect pointer sends a visitor to the main domain with a 301, so example.co.uk becomes example.com in the browser. This is the right choice for a domain you are retiring in favour of a new one, or when you want one canonical name for search engines and only bought the other domain to stop someone else using it.

Domain, subdomain or pointer

The rule we use: if the name gets its own site, its own files and probably its own mailboxes, it is a domain. If it is a section of an existing site with a name of its own, shop., app., staging., it is a subdomain. If it should show a site that already exists, it is a pointer. Domains and pointers count against separate limits in the package, so a customer who adds every spare domain as a full domain may hit their domain limit while pointers go unused.

Wildcards

A wildcard, *.example.com, is not a checkbox on any of these pages. It starts in DNS Management with an A record for *, so every unknown subdomain resolves to the server. What then answers depends on Apache: DirectAdmin does not create a wildcard virtual host by itself, so the admin adds one for the domain under Admin Level → Server Manager → Custom HTTPD Configurations. The certificate side is simpler, since DirectAdmin can issue a wildcard Let's Encrypt certificate when it hosts the domain's DNS, and 1.709 made that check faster.

Test before DNS moves

When a domain is being moved from another host, add it in DirectAdmin first and test it before changing DNS by putting a line in your own computer's hosts file that maps example.com and www.example.com to the server's IP. When it looks right, change the nameservers or A records; when they have propagated, request the certificate. On VPSPioneer free migrations this is exactly the order we work in.

#directadmin#domains#subdomains#dns

Keep reading

More from DirectAdmin

All guides

DirectAdmin

How to Create Packages and User Accounts in DirectAdmin

Reseller and user packages in DirectAdmin, the limits inside them, creating a reseller and a user, shared versus owned IPs, and suspending or deleting accounts.

4 min read →

DirectAdmin

DirectAdmin for Beginners: A Tour of the Evolution Skin

How DirectAdmin's Admin, Reseller and User levels fit together, how to switch levels and log in as a user, and where the ten everyday jobs live in Evolution.

4 min read →

DirectAdmin

DirectAdmin First Steps: 10 Things to Do After Installing

The ten things to set on a new DirectAdmin server before hosting anything: panel SSL, hostname, nameservers, updates, CSF, brute force blocking and backups.

4 min read →