How to Merge Multiple Domains

This post was published Tuesday February 19, 2008 filled under article.

 

How to Merge Multiple Domains

Post Meta
  • Feb 19, 2008
  • no comments

  • Tags
  • In the past, I’ve wanted to change my domain name, leaving the web site’s content untouched only swapping the URL. When your in a situation where you have a lot of links that are indexed by search engines and other URLs out on the web that reference an old domain name (dugg articles, link backs etc). You don’t want to lose that traffic to a 404 error page.

    For one you want your old domain to just point to your main main site/new domain and secondly if someone attempted to access a URL that referenced the old domain (http://www.olddomain.com/2007/12/11/complete-wordpressvbulletin-bridge/) you would like that link to be accessible and working while only changing the reference from olddomain.com to your new domain (http://www.newdomain.com/2007/12/11/complete-wordpressvbulletin-bridge/).

    How do I do this?
    Pending on your web host, it can be as easy as using your domain manager and just pointing the multiple domains to the same directory on your server, which is how I accomplished this in the past on GoDaddy. Now that I’m on Media Temple this must be done via SSH, using a symbolic link. Basically you have to remove the folder that contained the data for your domain or you can also rename it to your new domain to avoid moving all the files on your server to the directory of the new domain. Then you need to create the symbolic link, linking your old domain to your new domains directory (where all the data files are). This is done like so:
    1. The first step is obvious, you need to make sure your new domain is posting to the correct name servers of your server use your old domain name as a reference if you are unsure.
    2. Using an FTP or SSH rename the directory on your server that is associated with your old domain name; {SERVER ROOT}/domains/olddomain.com/ to the name of your new domain; {SERVER ROOT}/domains/newdomain.com/. Keep in mind once you do this, your site will be down until the process is complete.
    3. Now you want to connect to your server via SSH. I used a terminal on a Linux machine.

    ssh serveradmin%example-server.com@example-server.com 
    cd ~/domains
    rm -rf olddomain.com 
    ln -s newdomain.com olddomain.com

    4. The final step is to ensure you don’t have any configuration files or records in your data base that references your old domain as the home page. In my case since I am running Wordpress there are two fields in my database that needed to be updated manually. These fields are ’site_url’ and ‘home’ which are located in the wp_options table of your database. If you do not have access to your DB tables then alternately you can add the following lines to your wp_config.php file to update those records.

      define('WP_SITEURL', 'http://www.newdomain.com/');
      define('WP_HOME', 'http://www.olddomain.com/');

    5. Now test out your domains. They should both direct you to your new domain, not matter what permalink you try.

    If you have any questions or feel that I was unclear about something please feel free to email me at mikecicc@gmail.com and I’ll get right back to you. Thanks for reading.

     
     

    Leave A Comment