skip to Main Content

I have a blog (www.billoblog.com/wordpress) that I am trying to migrate to a new vps at www.forensicpath.us/wordpress. I managed to get the wordpress directory moved and changed the config file to point to forensicpath.us. I then moved the database over and got some odd behavior.

At first, the blog’s front page came up fine, but when I clicked on one of the posts, it linked to the post on the old blog site (which is still up). Aha! I said. I gotta change the permalinks. So, I went to the sql file I had moved across and, using vim, did a global change of billoblog.com to forensicpath.us.

Now, when I click on a post, it shows the permalink I want to see, e.g. https://www.forensicpath.us/wordpress/index.php/2024/09/19/pathology-cases-agenesis-of-the-corpus-callosum/ instead of https://www.billoblog.com/wordpress/index.php/2024/09/19/pathology-cases-agenesis-of-the-corpus-callosum/ but now I get 404 page not found.

Interestingly, I can edit the pages — when I go into Dashboard -> Posts -> Edit post, the correct information shows up. I don’t know if it’s pulled locally or reaching back to billoblog.com or what.

Obviously, manually editing the sql backup file was probably not the brightest thing to do, but I don’t know how to update the permalinks and the data the permalinks should point to. I’m stumped.

2

Answers


  1. It could be one or any of Permalink settings, web server (nginx) configuration, WordPress settings. I used to do this all the time years ago!

    Back up your site’s sql file/database, wp-config.php and nginx configuration and save them somewhere suitable like your home folder. Then you can try a few things.

    Here are some steps to resolve the issue:

    • Instead of manually editing the SQL file, use a tool designed for WordPress migrations. "WP-CLI" or plugins like "Better Search Replace" can handle serialized data correctly.

    If using WP-CLI (assuming it’s installed on the new server):

    wp search-replace 'https://www.billoblog.com/wordpress' 'https://www.forensicpath.us/wordpress' --all-tables

    Or open your text editor again and search in the sql file. Maybe a few things were missed?

    • Check server config:
      It may need to be something like:
    location /wordpress {
        try_files $uri $uri/ /wordpress/index.php?$args;
    }
    

    Also, if you’re using some default prefix for handling .php:

    location ~ .php$ {
        fastcgi_split_path_info ^(/wordpress)(/.*)$;
    }
    

    If it used to be:

    location ~ .php$ {
        fastcgi_split_path_info ^(.+?.php)(/.*)$;
    }
    

    Remember to reload your nginx config and get it restarted.

    • Check wp-config.php:
      Ensure that the WP_HOME and WP_SITEURL constants are set correctly if they’re being used:
    define('WP_HOME','https://www.forensicpath.us/wordpress');
    define('WP_SITEURL','https://www.forensicpath.us/wordpress');
    
    • Regenerate permalinks:
      In the WordPress dashboard, go to Settings > Permalinks and simply save the settings again without changing anything. This should flush the rewrite rules.
    Login or Signup to reply.
  2. alternatively you can use plugin to replace old URL with new URL.

    Better Search Replace: This plugin simplifies the process and takes care of serialized data. It’s a user-friendly alternative to running raw SQL queries and can be run directly from the WordPress admin.

    You can also use dry run feature to test the result before actually applying it. make sure to not to replace guid data.

    Link : https://wordpress.org/plugins/better-search-replace/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search