Broken links on old website after migration

I recently migrated my Wordpress website to a different host and updated the DNS. I’m keeping the old site running a little longer as a backup until the final touches have been made on the new site. After pointing my domain name to the new host, I can still visit the old website via IP address, but the image links and other parts fail to load.

When I look at the web console I’m seeing 404 (Not Found) errors for CSS and JS scripts. How can I fix the broken links and view my old website without having to rollback the DNS configuration?

1 Reply

It sounds like your domain name was part of the URL path to those files. If you’re able to access the admin panel and the only broken links are images, posts, pages, comments, and custom fields, then a number of plugins can help you out. However, if the site is failing to load the CSS and JS scripts then you probably can’t access the admin panel at all. In this case you would need to manually modify some database values.

Note: This example uses wordpress as the DB name and wpuser as the DB user. Replace these with the actual values you set during the initial Wordpress configuration.

Login to MariaDB and select the database for your Wordpress site.

mysql -u wpuser -p

mysql> use wordpress;

Change the home and siteurl values to your IP address (replace $IPADDRESS$ with your actual IP address).

mysql> update wp_options set option_value="http://$IPADDRESS$" where option_name="home" or option_name="siteurl";

Verify the changes.

mysql> select option_name, option_value from wp_options where option_name="home" or option_name="siteurl";

+-------------+-----------------------+
| option_name | option_value          |
+-------------+-----------------------+
| home        | http://$IPADDRESS$    |
| siteurl     | http://$IPADDRESS$    |
+-------------+-----------------------+
2 rows in set (0.00 sec)

This should resolve your issue.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct