Support » Fixing WordPress » Old url’s in database after moving to new domain

  • I have migrated a website from one domain to antoher new domain, using the UpdraftPlus Premium Migrator plugin option.

    In the Migrator plugin I used the option “search/replace sitelocation in the database (migrate)”

    Now when I look in the database I see this:

    – in kboa_options the “option_name” for “siteurl” and the option_name for “home” are both showing the new url, so this is good.
    – in kboa_posts under “guid” all displayed URL’s show the old url’s, so not good.

    I did another “search and replace” with the UpdraftPlus premium plugin option but this did not change anything.

    I also run the wp-optimize plugin, but this did not change anything either.

    However, the website seems to be working okay!

    Is this a common issue when moving wordpress sites from one domain to antoher domain. And is there a reasson why the url’s changend properly in _options but not in _posts ?

    Can I change the url’s manually in the database _posts section? Or is it better to try another “search and replace” plugin?

    Thank you very much for your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Alwin!

    If you want to change url’s manually you can do that with this sql:

    `UPDATE kboa_posts SET guid = replace(guid, ‘http://www.oldurl’,’http://www.newurl’);

    UPDATE kboa_posts SET post_content = replace(post_content, ‘http://www.oldurl’, ‘http://www.newurl’);

    //edit: thanks @dorzki for correction!

    Regards

    • This reply was modified 1 year, 5 months ago by KacperSzarek.
    • This reply was modified 1 year, 5 months ago by KacperSzarek.

    I wouldn’t suggest running the following query:

    UPDATE kboa_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

    Some of the values on postmeta table are serialized, and doing the following might break those values.

    • This reply was modified 1 year, 5 months ago by Dor Zuberi.

    Dor Zuberi, what do you mean with “Some of the values on postmeta table are serialised, and doing the following might break those values”?

    What is serialised? Could you please explain to me?

    Yes, some plugins and even WordPress saves array values to the database, and in order to do that, they serialize the array.

    For example – The following array:

    array(
      'name' => 'Alwin',
      'username' => '@wp-opti',
     );

    When serialized it will look like:
    a:2:{s:4:"name";s:5:"Alwin";s:8:"username";s:8:"@wp-opti";}

    The number represents the length of the value, and when you change the domain it usually changes the length, which will break the serialization.

    Lett me ask another question: since the website seems to be running without any problems, do i have to change the old url’s anyway or can I just leave it as it is now?

    If your websites works perfectly, there is nothing else for you to do.

    Basically you only need to change the URL on the wp_options table or via the Settings -> General page.

    WordPress will automatically change the url of the post.

    I did some more research and found this information:
    https://codex.wordpress.org/Changing_The_Site_URL#Important_GUID_Note

    In other words: the fact that in kboa_posts under “guid” old url’s are displayed is correct, this is just how it suposed te be!

    As this info syas: Never, ever, change the contents of the GUID column, under any circumstances.

    That is correct, this is why i wrote that you only need to change the url using settings section.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Old url’s in database after moving to new domain’ is closed to new replies.