ranthmath with cdn network sitemap issue

#24758
  • Resolved Harun Shekh
    Rank Math free

    Suppose My website is example.com and my website all images are delivered(CDN) from cdn.example.com.

    So here is my question of how I index images?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Image Index SEO Issue with CDN

    I have a similar issue with this case:
    https://crunchify.com/maxcdn-and-wordpress-image-index-seo-issue-in-google-search-console-fix-cdn-image-links-and-avoid-duplicate-content-penalty/

    The article shows how to fix it, but it only works for YOAST.
    Can I do something like that with Rank Math? 😀

    The case:
    I’m using CDN with subdomain cdn.domain.com; they serve the images at cdn.domain.com/image.jpg

    The problem is when I activated the Image URL in Rank Math Sitemap; the plugin serves URL as my root domain. Not the CDN URL.

    Hope you guys understand what I’m saying
    null

    Todd
    Rank Math free

    Hi Harun,

    Thanks for getting in touch with us.

    Please use this filter in your theme’s functions.php file to include your CDN URLs in the sitemap:

    /**
     * Filter to Add CDN Image URLs in the Sitemap
     *
     * @param string $src  Image URL.
     * @param object $post Post object.
     */
    add_filter( 'rank_math/sitemap/xml_img_src', function( $src, $post ){
        $src = str_replace( 'http://domain.com', 'https://cdn.domain.com', $src );
        return $src;
    }, 10, 2);

    Do change the domain to your actual domain name.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘ranthmath with cdn network sitemap issue’ is closed to new replies.