How can I remove redirects from the sitemap.

#391140
  • Resolved Yvonne
    Rank Math free

    Dear support team,
    there are 8 302 redirections in my sitemap. How can I remove them.
    Thanks for your help.
    Best regards
    Yvonne

Viewing 5 replies - 1 through 5 (of 5 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.

    The URLs should be removed from your sitemap automatically if they are already redirected. Could you please try adding this filter to your active theme’s functions.php file?

    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    After doing so, flush the Sitemap cache by following this video screencast: https://i.rankmath.com/pipRDp

    If the issue still persists, here’s a filter to manually remove URLs from your sitemap:

    add_filter( 'rank_math/sitemap/entry', function ( $url, $type, $object ) {
    
            $urls_to_skip = array(
                    'https://yourdomain.com/redirected-URL-1',
                    'https://yourdomain.com/redirected-URL-2',
                    'https://yourdomain.com/redirected-URL-3',
            );
    
            if ( isset( $url['loc'] ) && in_array( $url['loc'], $urls_to_skip ) ) {
                    return false;
            }
    
            return $url;
    }, 10, 3 );

    You may need to update the URLs in the filter with the actual URLs that are still showing in your sitemap.

    I hope that helps.

    Thank you.

    Yvonne
    Rank Math free

    Hello,
    thanks for trying, but no, both ways do not work at the moment.
    Any idea why?
    Best regards
    Yvonne

    Hello,

    In this case, head over to Rank Math > Sitemap Settings > Tcb symbols and disable this option:

    Disable

    Once done, clear your website and browser’s cache and check again.

    I hope that helps.

    Thank you.

    Yvonne
    Rank Math free

    Thank you. That works best.
    Best regards
    Yvonne

    Hello,

    We are super happy that this resolved your issue.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

You must be logged in to reply to this ticket.