Setting up Ubuntu Server on Amazon EC2 for hosting multiple domains with wildcard subdomains
Posted
by
Ashish Kumar
on Server Fault
See other posts from Server Fault
or by Ashish Kumar
Published on 2012-06-17T17:48:57Z
Indexed on
2012/06/18
3:18 UTC
Read the original article
Hit count: 490
I'm trying to set up multiple domains on my Amazon EC2 micro instance running Ubuntu Server 12.04. I installed Apache correctly and set up virtual hosts but having problems with wildcard subdomains.
This is what my httpd.conf file looks like
NameVirtualHost *:80
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /home/username/domains/%0/html/
</VirtualHost>
My DNS records (on Amazon Route 53) are:
domain.tld A 1.2.3.4
*.domain.tld A 1.2.3.4
If i create a test.domain.tld
directory with the html
subdirectory, it works fine. But what I want to do is to redirect *.domain.tld
to domain.tld
in case there is no directory for the sub-domain accessed. I would also like www.domain.tld
to redirect to domain.tld
. The system should also work if I decide to host another website, example.com
, on the server.
I tried Googling a lot but without any luck. Suggestions?
© Server Fault or respective owner