0

I have the following set up for a client:

Wordpress hosted at siteground.com with externalhost.com/blog => working Wordpress Installation.

AWS App "myapp.com" managed by Amplify with a rewrite for /blog which should lead to externalhost.com/blog but show the user myapp.com/blog.

I then switched the siteurl and home in the wp-config.php file:

define( 'WP_SITEURL', 'https://myapp.com/blog' );
define( 'WP_HOME', 'https://myapp.com/blog' );

It pretty much works, but there are some cases which aren't working. So far I have noticed: Pagination in the pages section keeps the links for the next page with externalhost.com/blog. Menu Section links redirect to the externalhost.com/blog part.

It feels that not everywhere in the Wordpress the link has changed above all in the pagination I wasn't able to find a solution. Maybe someone has experienced the same behaviour or ideas where I can modify those behaviours?

tilimani
  • 35
  • 6

2 Answers2

0

When switching the site url or moving the site to new hosting etc I have found i need to do a search & replace in the DB which can be done with a plugin like: https://wordpress.org/plugins/better-search-replace/ search for the old url externalhost.com & replace with the new url myapp.com this should resolve your issue, the plugin usually allows you to do a dry run before making the changes.

Also a another way to do a migration is also use a plugin like: https://wordpress.org/plugins/all-in-one-wp-migration/

Once your done with the plugins you should be able to remove them from your project

Nick_O
  • 429
  • 5
  • 18
  • Exactly. Making all the changes necessary to migrate a site from one URL to another is gnarly detail-oriented work if you stick-build it command by command. Use a migration plugin; their authors have debugged many if not most of the weird edge cases you have to consider. – O. Jones Apr 23 '23 at 23:45
  • Sorry didn't mentioned it, but I already did it. The problem I believe is its host-server and url-address are different. And that probably the pagination for example uses a dynamic variable which asks for the host-server and not for the site_url or home variables – tilimani Apr 24 '23 at 06:51
  • In the pagination for example it creates the link like to following: $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); But this takes externalhost.com as link and not the myapp.com url. Tough if I do in the console window.location.host it return myapp.com – tilimani Apr 24 '23 at 06:59
0

I got it working, doing the following in the wp-config.php

$_SERVER['HTTP_HOST'] = str_replace ('externalhost.com', 'myapp.com', $_SERVER['HTTP_HOST']); 

Now it works.

Reference: Change value of $_SERVER['HTTP_HOST'] on Bitnami Wordpress behind Azure CDN

tilimani
  • 35
  • 6