DNS redirect domain.example to www.domain.example [closed]

You could make www.example.com the A record and all the other domainnames CNAMEs of www.example.com. But this only “solves” that if the IP address of www.example.com changes you don’t have to alter the other DNS enties as they are aliases.

So on the DNS level there is no way to enforce a redirect. And for a good reason because DNS is used for more then only HTTP. For example if all request for example.com would redirect to www.example.com your email addresses will change to user@www.example.com.

So for HTTP redirection you will have to use an HTTP solution. This can be at the webserver level (mod_rewrite, in code, JavaScript (ugh), etc..) but you could also have a proxy in front of your webserver to handle this.

Leave a Comment