This is a case study of a blog I recently moved from a sub-directory (/wordpress) to the root directory (/). You can get some interesting tips by reading this or better still, assign the move to us at a nominal cost and save yourself all the hair-pulling 🙂
Step 1: The site was on Cpanel, so I took a full backup of the site to avoid chances of a major disaster happening if something went wrong (you know the Murphy’s laws, don’t you?).
Step 2: I upgraded the current blog (at /wordpress) to the latest version so that the database structure will be up to date.
Step 3: I downloaded all the files in the root directory to a local folder so that I can replace the overwritten files, if any are required.
Step 4: I then uploaded a full copy of the blog software to the root directory (public_html folder as this was a cpanel site). If there are any special plugins used, you should download the software from the previous location and then upload this in the new location so that the plugin files are also uploaded.
Step 5: I uploaded the wp-config.php fie in the root directory so that WordPress will refer to the same database.
Step 6: I accessed the database through PHPmyadmin and opened the wp_options table. Updated the values of the site_url and home options to http://www.domain.com by replacing http://www.domain.com/wordpress.
Step 7: Now I accessed the blog through the root URL and it opened fine. However I noticed that the posts were still being linked to www.domain.com/wordpress/postname/id.
Step 8: I accessed the admin console and recreated the Permalinks so as to update all the post URLs.
Now the whole blog was working fine without any issues.
Lastly, I needed to make sure that Google and other search engine would redirect the old indexed /wordpress/post URLs to the new ones. For this, I edited the .htaccess file in the root directory.
Inserted the following code before the # BEGIN WORDPRESS section (if you don’t keep this code out of the WORDPRESS section, WordPress will remove this when you update Permalinks or do any other act that works with .htaccess file).
rewriterule ^wordpress(/.*)? $1 [L,R=301]
This effectively creates a permanent redirect for all files with /wordpress/something name to /something names.
Bingo! The blog is now accessible from the root directory of the domain. You may like to rename the /wordpress directory to /oldwordpress directory and keep it for a few days, then delete it when things have stabilized.
Now you can move your blogs around as and when you wish. However if you are techno-shy or don’t have time to play with all these wordpresses and PHPmyadmins, feel free to assign your “move my blog” cases to us. You can write to me at arun AT ebizindia DOT com (you know how to convert that to a working email address).