URLs to images get messed up after migration

The question:

I migrated a website from one host to another, and I am having a weird issue I never encountered before. The urls to images in html are fine, but the full path to the image has a broken url, the domain outputs twice.

So here is the code generated for an image:

<img src="subdomain.domain.com/wp-content/uploads/2013/12/aleksandra.jpg" class="attachment-full wp-post-image" alt="aleksandra">

And here is the full path to the image in inspector:

http://subdomain.domain.com/subdomain.domain.com/wp-content/uploads/2013/12/aleksandra.jpg

If you need more info please do not hesitate to ask. Any help is much appreciated.

Thanks

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Back up your database (this is very very important) and download and install “Velvet Blues Update URLs” plugin. On the settings page enter in the old URL field http://subdomain.domain.com/subdomain.domain.com

Enter in the new URL field the URL of your website. Select all options and click “Update”. Update your permalinks as well.

Method 2

You should use a plugin like WP Migrate DB which enables you to enter the new site address and server path before exporting the database. This does a search find and replace which you may need to do now using a solution like https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

“Velvet Blues Update URLs” plugin is another solution or export your DB again.

Method 3

I figured out the problem, when I was exporting the database using Migrate DB plugin, I didn’t put the http:// before the new domain… so all the internal links were broken.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment