Changing the location of a WordPress installation isn’t as harrowing as it may sound. Although no tools exist to do it automatically, some knowledge of the Linux command line and MySQL makes it do-able. This post is a summary of the steps I performed to relocate my blog folder; this assumes you are hosting under Linux, MySQL, and cPanel. Take a gander at the official Moving WordPress documentation before you begin.
Make a Backup
Be sure to make a backup of your installation.
Change the Current Blog Folder
Rename your existing WordPress folder (i.e.: /journal) to the new name. FTP or ssh (i.e.: mv journal blog) can be used for this.
Update the blog path settings within the admin panel.
Updating Paths in the Database
If your blog posts contain images or links using the old folder they must be changed. There is a simple SQL command which performs a search and replace. I suggest using phpMyAdmin instead of MySQL’s command line.
Take a look at your wp_options table in phpMyAdmin. You may find that plug-ins are using your old path in their settings which may be not accessible through the admin interface.
Don’t Break Trackbacks
If anyone is linking to your blog they’ll be using the old folder name. To ensure those links don’t break with your folder we can use a symbolic link and a 301 redirect.
Login to your Linux hosting account using ssh and navigate to the root folder of your web site such as public_html. Enter the following command:
ln -s /path/to/new /path/to/old
Replace /path/to/new and /path/to/old with the absolute folder names. For example:
ln -s /home/your-domain/www/blog /home/your-domain/www/journal
You may be tempted to add a redirect using cPanel but don’t – the symlink above is doing this for you.
Unfortunately, permalinks still won’t work. For example, a permalink of http://your-blog/journal/2008/06/my-post will generate a 404 Not Found instead of redirecting to http://your-blog/blog/2008/06/my-post. Don’t bother with the Redirection plug-in because it doesn’t build a library of prior permalinks.
Instead, use Alexandra’s technique to modify your .htaccess file and all of your old permalinks will 301 properly.
Related posts:
- Integrating Google AdSense and WordPress without a plugin
- Moving DFS from one Windows server to another
- Making blogs (mobile) browser friendly
- PHPlist, Drupal, and magic_quotes





