I’ve migrated many WordPress sites before, but now I’m having an issue I just can’t seem to solve. Some, but not all of the links are not loading properly.
I’m migrating from local.dev to example.com/test.
In my database options, I have both options set to example.com/test.
I doubled checked the options in the WP backend, and they’re example.com/test.
I’ve updated my permalinks.
All of the pages work, all of the links work, but a few references to images, etc do not – they’re loading example.com/ instead of example.com/test.
I think it might have to do with the .htaccess file, because I can’t update it from the FTP side. If I delete it and update permalinks, no .htaccess file is created. I don’t have access to any server side overrides, only the files.
In my MAMP vhosts, I have SymLinks Override set to All, but I can’t edit anything like that on the live host.
The links that aren’t working are along the lines of $image = get_post_meta(37 ,'_my_meta',TRUE)['img'];
which should return
http://www.example.com/test/wp-content/uploads/image.jpg
but instead returns
http://www.example.com/wp-content/uploads/image.jpg
.
Using bloginfo('wpurl');
returns http://www.example.com/test
, and all similar ones return properly (site_url();
, 'template_directory'
, etc.
In the end, the site is going to go on http://www.example.com
without the subdirectory anyway, but I’m sure I have to get it to work properly to prevent future errors.
I also updated to the newest version of WordPress at some point, not sure if that could cause any issues.
I believe the issue deals with media and links placed in content items.
I use to do some manual SQL queries to fix this but now I run this plug-in https://wordpress.org/plugins/automatic-domain-changer/
The plug-in will go through all the content and make the needed changes.
this meta information is stored in the DB. then to make the migration you have to change all the old URL in the DB before to import it in the new place