If the URL is changing from example.com
to www.example.com
for users, then there IS an actual redirect happening. However it has nothing to do you with CNAME
record, because CNAME
s can't cause redirects. They simply point a domain or subdomain to the same server as another host name. So your CNAME
record is causing both your bare domain and your www
subdomain to resolve to the same server, but your web server is what is causing the redirect. To solve this problem, you won't need to touch your DNS records at all. Instead you'll need to modify your web server configuration.
Within Apache is is very common to point both the bare host name and the www
subdomain to the same directory and configure the redirect using rewrite rules in .htaccess
. If that is the case, you should delete the rewrite rules or change them to make the redirect go the other direction.
It is also possible to configure different virtual hosts for the bare domain and the www
subdomain and use redirect
directives in one or the other. If that is the case, you will need remove the redirect
directive from one of your virtual hosts and add it to the other.
Another possibility is that you have a virtual host for www
but some default catch-all virtual host for every other name that is pointing to your server that redirects. If that is the case, you should create a new virtual host for your bare domain, or add a ServerAlias
to your virtual host for your www
subdomain so that the same virtual host also handles the bare domain.