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