I have a domain, let's say mydomain.com
. I'd like to redirect www.mydomain.com
to the naked domain, mydomain.com
. So I set up the following DNS. (The IP is just for show)
A mydomain.com 192.168.0.1
CNAME www mydomain.com
What happens though, is that Apache serves my default site (which is empty), rather than the mydomain
site. Since I'm hosting multiple domains, I have:
/etc/apache2/sites-available/default
/etc/apache2/sites-available/mydomain
/etc/apache2/sites-available/myOtherDomain
/etc/apache2/sites-available/yetAnother
The start of /etc/apache2/sites-available/mydomain
looks like this:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.com
ServerAlias mydomain.com
What's wrong with this setup that's it's not redirecting www.mydomain.com
to mydomain.com
? Thanks for your help.
host
ornslookup
)? Did you also make sure that there's no other DNS A record for the www-subdomain or perhaps a wildcard A-record (*.mydomain.com)?