"Those who do not want to imitate anything, produce nothing." - Salvador Dali

How-to: Change the URL of a WordPress Multisite
Aug2011

Tags: , , , , , | 3 Comments

WordPress has a great feature that allows for running many sub-sites off a single installation. I can install WordPress on eliotche.com, and then have sub.eliotche.com, sub2.eliotche.com, etc up and running with much less hassle then setting up a completely new WordPress install each time. All it takes is a few tweaks, outlined here.

However, there’s not much information available on how to move a WordPress multisite from one domain to another.

I’ve been working on a new site, and needed to migrate the WordPress multisite installation from the development space to a live server. Since migrating a multisite install is much more complex than moving a regular WordPress site, I thought I’d offer up a short guide. It helps to have SSH access to both the target and source servers, though FTP and phpMyAdmin access should suffice.

There are two key tasks for a successful migration:

  1. Change the domain and absolute path in your mySQL database
  2. Change the database and domain_current_site information in wp-config.php


An extended guide that outlines what to do from start to finish:

A. Pack up your WordPress files and mySQL database:

  1. Backup the mySQL database using SSH (tutorial) or phpMyAdmin (tutorial). SSH is recommended if the file size of your database is large.
  2. Backup your files using TAR (tutorial) or FTP. I highly recommend using TAR, since it preserves the file permissions.

B. Transfer the files to your target (new) server:

  • Use WGET (tutorial) or FTP to get the TAR file onto the new server. WGET transfers the file directly from target to source.
    • Then uncompress the TAR file (also using the TAR command)
  • If using SSH, also transfer the mySQL file to the new server

C. Setup the new database:

  1. Create a mySQL database on your new server using the built-in server management software  (e.g. CPanel or H-Sphere) or the CREATE DATABASE command. The easiest way is to use the management software that comes with your server, if available.
  2. Create a user with administrator rights to the newly created database (tutorial).
  3. Edit your backedup mySQL database file using a text editor (I recommend gVim)
    • Change the domain: e.g. if your development domain is test.org and your new domainis main.org, replace all instances of test.org with main.org in the database
    • Change the absolute path: e.g. if your development path is /home/user/public_html/eliot, replace all instances of it with the new absolute path (your web host likely provided you with this info, if not: try this)
  4. Import your edited, backedup database into the new database (tutorial).

D. Setup Apache (if necessary):

  • Depending on whether you’re using sub-domains or sub-sites, follow these instructions.
  • If you’re using sub-domains, make sure your web host supports it! (not all shared hosting services do)

E. Setup wp-config.php:

  1. Change the database name, user and password according to what you did in Step C, above. (You may need to change the database host as well).
  2. The line define( ‘DOMAIN_CURRENT_SITE’, ‘sample.com’ ); should reflect the new domain name.

That’s it! Your website should now be functional on your new domain.


3 Comments on “How-to: Change the URL of a WordPress Multisite”

  1. 1 Penn said at 11:18 pm on August 19th, 2011:

    thank you. You’re right, it is much much easier with shell.

  2. 2 warren k said at 7:41 am on August 22nd, 2011:

    it works! Saved me some trouble.

  3. 3 Fredrik said at 7:25 am on November 22nd, 2011:

    Worked like a charm, thanks!

    One note for people about to do this: Make sure that you are consistent when entering your new address, I accidentally forgot “www.” in the wp_blogs table which rendered the Super Admin area inaccessible due to a redirect loop…


Leave a Reply