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!
- Log into your web host’s online control panel and create a sub-domain.
- 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.
- 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
- The steps from here on down are from the blog post mentioned above.
- Download the Database Search and Replace Script in PHP script (
searchreplacedb21.zip
). This was originally found here. - Extract
searchreplacedb21.zip
so that you see a file calledsearchreplacedb2.php
. - 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”. - Upload
maktub.php
to the root directory of your WordPress install. This is where thewp-config.php
file lives. - Go to the URL where
maktub.php
lives. - 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. - 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. - 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. - Leave the “Leave GUID column unchanged?” text box unchecked and click the
Continue
button. - 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
. - You will be on a new page with a “What to replace heading”. [To be continued]