-
Hi Team,
I need a support. I have added few redirections using the rankmath as below
https://xyz/asphalt-shingle-roofing redirects to https://xyz/myrtle-beach-sc-roof-replacement/I do not have any page “asphalt-shingle-roofing” in my site and I added a redirection only to other page for this but now I see the sitemap.xml is having the url https://xyz/asphalt-shingle-roofing which is now being reported as concern by google as page does not exist (& it is redirection).
As it is a non existing page so I am not sure how to add a “noindex” so that it can be excluded from sitemap.xml. In one of your tickets below code was mention to be used to add noindex but I really dobut it will work as the get_posts( array( ‘name’ => ‘asphalt-shingle-roofing’ ) ) function will return nothing as it is trying to fetch a non existing post & if $page will return false.
Please guide how to address the concern. I do not want the redirection page to appear in the sitemap.xml
/**
* Allows filtering of the robots meta data.
*
* @param array $robots The meta robots directives.
*/
add_filter( ‘rank_math/frontend/robots’, function( $robots ) {
global $post;
$page = get_posts( array( ‘name’ => ‘asphalt-shingle-roofing’ ) );
if($page){
$robots[‘index’] = “noindex”;
$robots[‘follow’] = “follow”;
return $robots;
}
return $robots;
});
The ticket ‘sitemap.xml non existing page url’ is closed to new replies.