blog url redirecting

Based on the code that you posted I can see you have created a Multisite installation. I’m assuming that is a mistake. I would suggest you delete you new installation, upload your old site backup and import your old database backup.

Updating the Database

Ok, now that things are back in place you need to update all the URLs in the database to run at the new address because WordPress uses absolute URLs. You can do this by editing the database directly through a tool like phpMyAdmin.

This is the part where I warn everyone to backup their database first but you already have one, right?

First and foremost, in the wp_options table you need to update siteurl and home to the new domain/IP that the site is running at. DO NOT include a trailing slash / at the end of the URLs. Something like this.

http://123.123.123.123/blog

Once that’s correct you should be able to log in.

Now, if you intend to run the site at the new address you will want to update the remaining URLs in the database. Links to media like images and PDFs will be broken otherwise.

There are 3 fields in 2 databases that need updating.

wp_posts table

  • guid
  • post_content

wp_postmeta table

  • meta_value

Here are the MySQL queries to update those. Swap out http://www.olddomain.com and http://www.newdomain.com with your addresses.

UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com', 'http://www.newdomain.com');

Finishing Details

Your site should be pretty much ready to run at the new address. There may still be other URL entries in the wp_options table that need to be updated. This is often data used by themes and plugins.

You can usually correct these in your theme settings, plugin settings, etc.

You can’t update the wp_options table with the queries I posted above because often the data is serialized and those queries will break everything.