Let’s say a WordPress blog previously accessible via http://old/ is now at http://new/. You’ve updated the Apache config, yet when accessing http://new/, you get redirected to http://old/, which no longer exists.
This is because WordPress still considers itself at the old URL. You could use the following SQL find/replace old URL instances with new, directly in the database:
1 | UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old/', 'http://new/'); |
But wait, you’re not done, there are more places to update..
With WordPress MU, all blogs share the same database. A number is added to standard WordPress table names for each blog. Main blog is usually wp_1_xxx, second blog that was created is wp_2_xxx, etc.
To modify a WPMU blog directly in the DB, one would usually want to identify which tables are used for which blog, to ensure the correct blog is being modified. Here’s a little shell one liner to do just that:
1 2 3 4 | $ CMD="mysql giantdorks --skip-column-names -Be"; TBS=$($CMD "show tables like 'wp%options'"); for TB in $TBS; do URL=$($CMD "select option_value from $TB where option_name='siteurl'") && echo $TB is for $URL; done wp_1_options is for http://giantdorks.org/ wp_2_options is for http://giantdorks.org/alain/ wp_3_options is for http://giantdorks.org/jason/ |