Issues with Headless CMS with Domain Redirections

#570496
  • Resolved Anonymous
    Rank Math free

    I have a site and I am using RankMath to set the Redirections and the SEO Meta tags. I have migrated to a Headless CMS setup and set my old WordPress site URLs to redirect to this new one. I came across the Headless CMS Support for the meta tags.

    But the problem is the redirection rules set. Once we hit the old URLs that have the tag information, the site redirectes and the API returns it’s HTML structure instead of meta tags JSON. Need Help!

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    For initial troubleshooting, please follow this guide to Rank Math’s REST endpoint: https://rankmath.com/kb/headless-cms-support/#num-2-allow-firewall-to-access-rank-maths-rest-endpoint

    Also, please disable redirects for the /wp-json/ path and all subfolders as it contains all WordPress REST API endpoints. Once the redirect has been disabled, you should be able to view and test all exposed endpoints.

    Hope that helps.

    Thank you.

    Anonymous
    Rank Math free

    Hi Reinelle,

    Sorry for the delayed response.

    We made it work using the WordPress redirections for now.
    Not sure why it didn’t work.

    But can you help me in understanding if we can pull the sitemap data for headless?

    Thanks,
    Ekansh

    Hello,

    Glad you got it working.

    But can you help me in understanding if we can pull the sitemap data for headless?

    Yes, you can pull the sitemap data from WordPress. Though, the sitemap will have the WordPress URL, you need to change the URL from WordPress to the actual headless URL. For that you can use the following hook in your functions.php file:

    add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
    	if(strpos($url['loc'], '/wordpress-folder') !== false){
    		$url['loc']= str_replace('/wordpress-folder', '/headless-folder', $url['loc']) ;
    	}
    	return $url;
    }, 10, 3 );

    Once you have added the filter above, flush the Sitemap cache by following this video screencast: https://i.rankmath.com/pipRDp, then check your sitemap.

    Hope that helps. Please let us know if you have questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Issues with Headless CMS with Domain Redirections’ is closed to new replies.