WordPress/Yoast SEO sitemap find and replace issue

So I have a WordPress site hosted on wpengine with Yoast SEO. So all the links in the site map are like https://example-site.wpenginepowred.com. We also use AWS cloud front to direct traffic to either the WordPress site or web app server so we can set up access to the sitemaps via cloud front to be accessible on www.example.com/sitemap for example but all the urls are still in the previous wpengine powered format Tried to add a find and replace to functions.php like the below add_filter('wpseo_xml_sitemap_post_url', 'replace_domain_in_sitemap', 10, 2); function replace_domain_in_sitemap($url, $post) { return str_replace('example-site.wpenginepowered.com/', '/www.example.com/', $url); } Notice the extra / before example.com. if I remove all the url content comes back as blank and with the extra it builds ok with https:///www.example.com. Any ideas why the sitemap doesn't like it without the extra /?? Just seems super weird that it does this?

Comment (0)

You’ll be in good company