WordPress slowly but surely has become the most popular open source CMS but most users did not start using it as a CMS for their websites. I also started using WordPress as Blogging Platform and had a custom built CMS to manage rest of my website. But with the arrival of WordPress 3.x, lot of features, hundreds of thousands of plugins and endless availability of premium and free themes have made it the most popular CMS for websites.
Due to number of reasons bloggers are using now WordPress as full fledged CMS for the whole website, more and more users are now moving WordPress from the Blog sub-directory to the root. Although it’s not that difficult to move to root, many pople just keep delaying it due to the established rankings, Google PageRanks to the individual posts and basically nobody wants to break a functional blog just to move it one step up due to fear of loss of traffic and/or revenue. Being an SEO myself, I know changing high ranking post URL (with Google PR) is the worst nightmare of any webmaster.
In this article, I’ll show you that you don’t really need to change the established URLs of old blog and it’s very easily avoidable. Not just that, you don’t really need to place redirects or make weird changes to whole lot of files for broken links. I’ll show you that you can make all these changes staying inside WP Admin Panel and without changing the permalink structure one bit. At the end of this exercise, you will have your website up and running on your new shiny WordPress theme and still retaining all your old blog posts on same URLs.
So here is the guide to move WordPress easily in 4 easy steps:
Step 1 – Update the website URL and Media Directory Path
Login to your WordPress admin panel and go to WP-Admin > Settings > General. Update the website address in two different address fields (URL). and “Site address (URL)”.
Now go to WP-Admin > Settings > Media and make sure that path is set to wp-content/uploads/, if it’s not set, update it to this value.
Step 2 – Move Files to the root
Now move all files from the sub-directory such as www.domain.com/blog/ to the root of website at www.domain.com including .htaccess file. Sometimes .htaccess file is hidden or not moved to the new location because old .htaccess is already there. Moving files usually takes dragging them from sub-directory (public_html/blog) into the root (public_html/).
Step 3 – Update .htaccess file
Open .htaccess file, and update RewriteBase /blog/ to RewriteBase /. Your default updated .htaccess file should look like this:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.php [L]
# END WordPress
Step 4 – Update the WordPress DB Content for Media paths and Links
Sometimes in our blog posts, we link to other blog posts. Those urls are now part of the content. Also, the images and other media files that we have uploaded and linked previously are also broken links due to the updated location of media files folder.
To update these paths and links easily from the WP Admin, use Search and Replace plugin. This plugin searches the strings in your database and replace the string with the provided value. You can search in ID, post-content, GUID, titel, excerpt, meta-data, comments, comment-author, comment-e-mail, comment-url, tags/categories and categories-description.
Install and activate the Search and Replace plugin and from WP Admin > Tools > Search & Replace.
Provide in the search field old and new media folder paths of your WordPress Blog. For instance, if you had previously installed the WordPress in blog directory, you will search /blog/wp-content/uploads/ and replace with /wp-content/uploads/ because this is now where the uploads folder has been moved. Please refer to the following screenshot for the guidance.
Step 4 – Make all Posts Categories as child Categories of ‘Blog’
This is the last but most important step and most probably the one reason you had been avoiding to move the WordPress until now.
Go to WP-Admin > Posts > Categories and create a new category with the old directory name (from which you moved the WordPress) such as Blog. Move all the existing categories under Blog category. Create a new menu item Blog in the main navigation using custom link option from WP > Appearance > Menus and link it to the www.domain.com/blog/.
That’s it.
Now go and check your website and blog. All your old posts are still working on the same old URLs and you have a working WordPress installation at the root of your website.
Hope that helps.
Cheers!