Migrating WordPress to a site with a subdirectory

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.

Read More

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.

Related posts

2 comments

  1. 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

    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

Comments are closed.