OK, so if you’re like me and you’ve created your blog, added a post or two and then realised that ‘blog’ just doesn’t sound right, or perhaps you want to get a keyword or two into the main blog URL for better SEO, then it shouldn’t be too tricky to change this without re-installing and setting up your blog.
Note: This post assumes you have installed your wordpress blog at www.yourdomain.com/blog-url/ and you have FTP and database access to your site. These steps worked for me, keeping my existing posts and plug-ins intact but I cannot guarantee that this will work in all cases!
1. Log in to your blog MySQL database – in many cases, this will be through phpMyAdmin. From the main menu, without selecting any tables, click ‘Export’. Make sure all the tables are selected on the export screen along with the ‘SQL’ radio button. Keep all other default options selected and check ‘save as file’ then GO, to export the entire contents of the WordPress database in one file.
2. Next we need to replace all occurrences of “/blog-url-title/” with “/new-blog-url/” within the saved SQL file. Dreamweaver has a very handy find and replace tool – like the one in Word, otherwise there are many text editors such as UltraEdit which will do the same.
3. Once you’ve replaced all url blog strings, go back to the MySQL database and “Drop” (delete) every table.. can be a bit daunting but as long as you have your backup saved SQL then you should be fine! Once deleted, go to “Import”, keeping all default options selected and browse to your updated SQL file with the renamed blog urls and GO. It might take a few seconds to upload depending on the size of the database.
4. Next, simply rename your blog folder via FTP to match your newly renamed blog URL… and then test – all should be working in your new blog location!
5. Finally, and perhaps most importantly, if your blog has been around a while, established a few links and good rankings then you will probably want to redirect the old blog link to the new, in a search engine friendly way. A ’301 redirect’ is what you need, which tells Google (and the rest) that your blog has permanently moved to another location.
You can do this using a PHP redirect from the main index.php file – however, modifying the .htaccess file (if your server uses Apache), to redirect all URLs, including all posts, would be even better if possible. If your server doesn’t use Apache, you should be able to achieve the same from within IIS on Windows.
You can create your .htaccess in notepad (just save as ‘.htaccess’) and using the below code should perform the 301 redirect this quite nicely.
Redirect 301 /old-blog-url/ http://www.yourdomain.com/new-blog-url/
Just drop the new .htaccess file into the old blog folder (which, if you’ve renamed it you’ll need to recreate) and viola – all old blog urls should now redirect to the new. You can check to make sure they are 301 redirecting by entering your old blog or old blog post url into a 301 friendly redirect checker.
If you don’t like the sounds of step 2 and 3, you could instead manually rename all WordPress blog URL strings within each MySQL table. There’s a couple of instances in the ‘options’ table, the ‘user’ table and also in every post you’ve created. This however could take a while depending on the amount of posts!