Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not knowledgeable at all about C-NAMES, A-RECORDS, name servers and the like, so just bear with me on this one:

I want to redirect to another domain I do own both domains and both domains run on shared hosting. When creating a subdomain, all I can do out-of-the-box is do a HTTP redirect (302, yuck!) or a frame redirect.
I also can set the DNS records on one host like nameserver, CNAME - but I would have know clue what I am doing.

Please explain to me how routing with nameservers works and how I should (even if not possible with my current host) redirect to with the user-visible URL staying at ""

share|improve this question
up vote 5 down vote accepted

Name servers do not route anything. Name servers respond to requests for names, and they eventually returns an IP. CNAME records return a name, which is then looked up to get the IP. The only thing you really can do with your DNS records is make sure that your name is set returns the IP address of a server that will accept the traffic and do what you want.

If you setup the web server with name-based virtual hosting setup, and the main name for that virtual host is then you could set an additional name for that virtual host In DNS you set the records to return the IP of the virtual host serving

The web site hosted on must used relative links wherever possibly or the user will quickly realize that they are now have been switched to a different domain.

... this is the crucial point. How would I do that?

Just create an A record that associates a name with an IP, or CNAME record that points to an A record that points at the IP you want.

DNS knows nothing. What you are asking for needs to be handled on the HTTP server.

Otherwise I could direct my domain at and make it look like it's my site?

You can point a DNS record at any IP address you like. In the case of HTTP, part of the request includes the host name you are trying to access. The Google web servers may choose to reject based on the hostname that is part of the HTTP request.

Setting up a DNS name to point at Google's servers is even supported if you are a Google Apps customer. There is a procedure you most follow to tell Google what name you will be using for a particular page. Google then adjusts their configuration accordingly.

If you are using some other protocol that doesn't include the hostname used to access then the server would have no way of knowing what is what. You can easily test this for yourself by creating a record like IN A, and then running ping, Google's DNS server will respond to the ping. The name you used to for the ping command is not included in an ICMP echo reply at all, only the IP address.

share|improve this answer
"In DNS you set the records to return the IP of the virtual host serving" <-- this is the crucial point. How would I do that? I can imagine that it shouldn't be possible to just "direct my domain at some other IP"? Otherwise I could direct my domain at and make it look like it's my site? – Dennis G Feb 1 '11 at 21:15

Why can't you just setup a .htaccess file (with a 301 redirect) in the folder that the subdmain is in.

For Example:

  1. Create a .htaccess file in the folder
  2. Setup your subdomain in Cpanel based on the above folder
  3. Edit that new .htaccess file and add the following code

    Redirect 301 /

With / being the root directory of your subdomain, and being where you want it sent.

Works for me.

share|improve this answer
I could, as I also have written in the OP. This doesn't hide anything though as the redirect is still seen by the user. The only true way is to use DNS to map the subdomain to the other domain. – Dennis G Nov 25 '12 at 12:45

The only complete solution is to setup a web server to listen for '' and redirect it to '' with HTTP redirect.

If you use a cname to point '' to '', the web browser will talk to the web server for '' but it will say "I'm looking for" which it may not be configured for. If you can configure the web server to accept both URLs, then cname will work fine.

share|improve this answer
Please, some more insight. When configuring my CNAME on> - all I would need is to have to accept this CNAME? What's that called? A-Record, a nameserver change? What is actually needed... – Dennis G Feb 1 '11 at 20:36

DNS redirects using CNAMES won't work the way you want them to on a shared host.

For our purposes, suppose you have a 'CNAME' record for that point to and an 'A' record for When you visit, a DNS server is first queried to determine the correct IP address. The DNS server will see the CNAME record and recursively determine the IP address for, which is then returned to your desktop.

Your browser will then contact that IP address, it it will ask for In fact, it doesn't even know exists.

If you had a dedicated box, you could get CNAMEs to work like you think they should, but you would forfeit the ability to use a name-based virtual host. With IP-based vhosts, any domain that points to a given IP will serve the same content.

To get your browser's address bar to say while the page is being served from, you may reconsider using the frame redirect provided by your host.

Another possibility, if your host provides mod_proxy, is to set up a reverse proxy in's virtualhost configuration:

ProxyPass /
ProxyPassReverse /

This will cause to provide's content while still reporting as the source domain.

share|improve this answer
Yes, that's what I was afraid of being on a shared host as the other server doesn't even have a dedicated IP address as many hosts share the same one... In the end the frame-based redirection is nothing else than a html page with frame src set to the other domain - that I can do with iframe as well and and run into cross-domain problems (e.g. Internet Explorer not accepting cookies) – Dennis G Feb 1 '11 at 23:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.