Warning: Trying to access array offset on value of type bool in /var/www/vhosts/tomelliott.com/httpdocs/wp-content/themes/tomelliott/single.php on line 12

Renaming your Wordpress Blog URL

22 January, 2011 by Tom Elliott

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!

Good luck! 🙂



Remove author & date link from WordPress (TwentyTen Theme) »


5 Comments

  • Andy Morley says:

    Hi Tom, have you tried some of the SEO plugins for WordPress?

    “All In One SEO” is an awesome plug-in. It let’s you change the Urls for search engine friendlyness. Also easily alter Title tags and Descriptions.

    Check it out. I’m not sure if it handles 301s though.

    Good post.

    Andy

  • tomelliott says:

    Hi Andy,
    I’ve tried one or two but not the All in One SEO you mention – might try it out to see if it handles the all important 301s 🙂
    Tom

  • Andy Morley says:

    wow… over a year ago when i posted here last, did you try All In One SEO?

    It doesnt do the 301’s like you said but i do use “Simple 301 Redirects” wordpress plugin, does exactly what it says on the tin… so to speak.

    Cheers

    Andy

  • Tom Elliott says:

    Hey Andy, I think I may have tried All in one SEO on one theme once but these days I only use a handful of SEO plugins from Yoast… the rest of the time I like to code direct in PHP because I like to have direct control.

    The Simple 301 redirects plugin suggested sounds good and I’ll have to give it a try next time I move a blog location

    Cheers

  • Matt Porter says:

    Hi guys,

    I usually create a new database on the new server, upload the backed up database in myphpadmin and then update the ‘site url’ and ‘admin url’ ‘s in the database table’s instead of using an editor locally. The main reason is because I usually backup and .gz the database so that its quicker when rolling out on the new server.