How do I redirect a domain

I have site hosted at a domain www.x.com. I have a newer version of the same site hosted at www.y.com. I would like to retire x.com, but for reasons of familiarity and pagerank, I need to keep the x.com domain for a while.

What are my options in regards to forwarding or redirecting users that arrive at x.com to y.com?

Ideally, I don't want to pay the hosting fees at x.com any longer, but I will if needed.


Solution 1:

Whatever you choose, you'll need to keep domain x.com registered.

Having done that you can setup an extra vhost on the server that handles y.com. You then change the A records for x.com to point to the same IP that y.com has (or use a CNAME if you prefer).

That vhost definition for x.com will redirect any traffic landing on x.com to y.com. If you use apache it would probably look something like this (where aaa.bbb.ccc.ddd is the IP address of the y.com server)

<VirtualHost aaa.bbb.ccc.ddd:80>
    ServerName x.com
    ServerAlias www.x.com

    RedirectMatch permanent ^/$ http://y.com$1
</VirtualHost>

The important part of that stanza above is the use of the 301, permanent, direct code, which is recommended by SEO experts to "transfer" the pagerank of one domain to another. I have heard this process can take some (read 6 or more) months to take effect

Solution 2:

Do not use the CNAME if you're planing to retire x.com. Use 301 permanent redirect instead.

If you'd use CNAME, Google (and other search engines) will keep sending users to x.com, while with 301, they'll send them directly to y.com.