I have performed a web search for the question but totally disappointed with the results. The case is to redirect all requests to domain.example
to subdomain www.domain.example
.
So what I have:
www.domain.example
- main website domain, all client requests should be redirected heredomain.example
- another website entry point for people not using www prefix, all requests should be redirected to www.domain.examplemydomain.example
- alternative website alias, all requests should be redirected to www.domain.examplewww.mydomain.example
- for people using www prefix, all requests should be redirected towww.domain.example
I understand this is possible using .htaccess
and PHP. But I want to figure out how this can be done using DNS only. I also understand that the result of the DNS query doesn't change what happens in the HTTP layer so the originally entered domain name will always be the one that's sent to the web server in the Host. So to rewrite domain.example
to www.domain.example
I will still need Apache mod_rewrite. But I want to do main part of work with DNS (CNAME and A records).
So the main question is what CNAME and A records each domain above should have?
www
subdomain, to that. – Jitters