Blog

How to Move a WordPress Install from a Directory to a Sub-Domain on the Same Web Host
Posted on October 14, 2013 in Command Line, Linux, WordPress by Matt Jennings

Some of the info in this post was taken from a post by David Coveney, James Whitehead and Robert O’Rourke or Interconnect IT! Thanks fellas!

  1. Log into your web host’s online control panel and create a sub-domain.
  2. Using a FTP Client, find the paths of where your WordPress install lives and where you want to place it. Copy those paths and paste them into a text editor.
  3. Navigate to the root of your server using a shell. Then type the example code below with the first path showing where your WordPress install lives and the second path showing where you want the WordPress install copied to:Note: Make sure there is a . and NOT a * after the first path of where the WordPress install currently lives. If you do not do this then you won’t copy hidden files, like .htaccess:
    rsync -avpzt /home/janelynch/example.com/wordpress-old-location/. /home/janelynch/newfileslocation.example.com
  4. The steps from here on down are from the blog post mentioned above.
  5. Download the Database Search and Replace Script in PHP script (searchreplacedb21.zip). This was originally found here.
  6. Extract searchreplacedb21.zip so that you see a file called searchreplacedb2.php.
  7. Rename the file an unusual word, preferably in a foreign language. You could name it something like maktub.php which means “it is written in Arabic”.
  8. Upload maktub.php to the root directory of your WordPress install. This is where the wp-config.php file lives.
  9. Go to the URL where maktub.php lives.
  10. On that page you under the “Load DB connection values from WordPress?” text make sure the “Pre-populate the DB values form with the ones used in wp-config? It is possible to edit them later.” checkbox is checked. Then click the Submit button.
  11. On the new page you will see a “Database details” heading. Enter the appropriate information in all the fields. For the “Server Name” field you will need to add the database host name. You do not need to fill out the “Charset” field. Click the Submit DB details button.
  12. You will now see a new page with a “Which tables do you want to scan?” heading. Click the first table in the listed, scroll to the bottom of the tables and then hold the Shift key and click the last row table to select all of the tables.
  13. Leave the “Leave GUID column unchanged?” text box unchecked and click the Continue button.
  14. If you see a pop up window that “Do you be sure that you selected the correct tables – especially on multi-site installs” click OK.
  15. You will be on a new page with a “What to replace heading”. [To be continued]

Leave a Reply