I’m having some trouble setting up subdomains.
Here’s what I’ve got going on.
I run a single webserver, with a single ethernet interface, a single IP address. Linux, with Apache2.
I’ve got a website going, domain.tld
No problems there.
I want to run sub.domain.tld on the same server, but I’m a little bit confused.
Here is my sites-available in apache:
NameVirtualHost * <VirtualHost *> ServerName domain.tld ServerAlias www.domain.tld DocumentRoot /domain </VirtualHost> <VirtualHost *> ServerName sub.domain.tld Document /domain/subdomain </VirtualHost>
Now, I’ve got the DNS entries for domain.tld and sub.domain.tld both pointing to the same IP address (my webserver)… with the vhosts setup as above, the webserver is supposed to be able to determine which site the user is trying to access via information in the request, right?
But that’s not happening.
If I navigate to domain.tld.
So it feels to me that I’m doing something wrong with wildcards, or else I have to point the DNS to something different.
Anyone have any suggestions?
I could workaround by just redirecting sub.domain.tld to domain.tld/subdomain, but that kinda sucks.