How to Fix Images Not Indexing on MaxCDN or WP Engine

I have been evaluating moving all my sites from WP Engine to Kinsta (which I will be doing, Kinsta is awesome!). I didn’t actually realize my images weren’t indexing until I was evaluating the Kinsta platform without MaxCDN enabled. I happened to click into my Sitemap and noticed a huge jump. The jump was all my images started indexing right when I moved to Kinsta. So I put two and two together and realized the only difference was MaxCDN on WP Engine. See the graph below. I moved back to WP Engine with MaxCDN and suddenly all my images dropped from the index again.

images not indexing

Even after following their tutorial of enabling the canonical headers and chatting with MaxCDN’s support my images were still dropping from Google’s index. This is a big problem that MaxCDN doesn’t seem to want to recognize is an issue.

[alert-note]If you are struggling with getting your images to index with MaxCDN follow the instructions below. I have tested this fix on multiple sites and can confirm that it works.[/alert-note]

Fix Images Not Indexing on CDN

Step 1

First we are going to add the MaxCDN canonical header as instructed by their support. Again this doesn’t fix the issue, but we will still enable it. This feature adds a HTTP header to your CDN assets to tell Google where the original file is hosted. So in your pull zone at MaxCDN click into the SEO tab and under SEO Settings enable the “Canonical Header.”

canonical headers maxcdn

If you stop here your images won’t index!

Step 2

Now enable your robots.txt file on your CDN. Make sure your CDN robots file and your local robots file in the root of your WordPress directory match. Notice I am specifically allowing the uploads folder where your images are located just to be safe. Enter the following:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-content/uploads/

maxcdn robots file

Step 3

We are now going to instruct Google to index the images on the CDN instead of on your local server. Now this isn’t ideal, but it seems to be the only solution that works. So we first need to add our CDN subdomain in Google Webmaster Tools. In my example, my custom CDN name is So in Google Webmaster Tools click on “Add a Site.”

GWT add site

Step 4

Input your custom CDN domain.

add cdn subdomain

Step 5

You now need to verify your subdomain. If you are running Google Analytics already on your main site simply choose choose alternate methods and verify with Google Analytics.

verify with google analytics

If not you can verify with an HTML tag on your main site.

verify with HTML tag

Once you click Verify you should see a successful message.

GWT succesfully verified

Step 6

Now we need to change the path of your images in your Sitemap file. This tutorial assumes that you are using Yoast’s WordPress SEO plugin. So in WordPress go to Appearance and click into “Editor.”

appearance editor

Step 7

Click into your functions.php file and place the following code into the bottom. Obviously change the code to match your domain. (also please backup your functions.php file before doing this if you aren’t familiar with editing this file)

function wpseo_cdn_filter( $uri ) {
return str_replace( '', '', $uri );
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );

add to functions file

Step 8

Now click into your Yoast sitemap, right click “view source” in your browser and you will want to verify that your sitemap’s image locations are now pointed to your CDN.

verifying url sitemap

Now wait a couple days and your images will now start to index again.

[alert-note]I implemented this sitemap trick on a Friday and my images were indexed again by Sunday afternoon.[/alert-note]

images indexing again

I can’t take full credit for this as Kumar Gauraw originally published this:

Also if you are curious to see how much traffic you are getting from your images then check out this great tutorial from AJ on Tracking Image Search in Google Analytics.

As always feel free to leave your comments below and let me know how it goes!

Get More Stuff Like This

Marketing, WordPress, Blogging Tips, SEO and Reviews, twice a month.

Thank you for subscribing.

Something went wrong.

Brian Jackson

Co-founder at forgemedia. Blogger and entrepreneur obsessed with SEO, marketing, and web performance. Connect on Twitter @brianleejackson.

39 thoughts on “How to Fix Images Not Indexing on MaxCDN or WP Engine”

  1. Pingback: How to implement SEO with MaxCDN - WPBrigade
  2. Hi brain, i have a question. Do we need to add sitemaps for our new websites ( , etc.) or should we just add the new custom domain name to our google webmaster tool and then leave it like that? And we will see the indexed number in our local domain name right?

    • Hey Burak!
      You don’t need to add individual sitemaps. Simply add your main sitemap file to your root domain in Webmaster Tools. Make sure to setup your subdomains cdn and cdn1 in webmaster tools and claim them, but you don’t need to do anything with them, just claim them. Your images can be distributed over multiple CDN subdomains but they will simply index in Google with the one subdomain. Otherwise you would be creating a duplicate content issue. Hopefully that makes sense.

      • Hi, I have got the same problem, tried you solution, still not indexing, any input?.
        I added the subdomains, sitemap is fine with the cdn url in there, max cdn header. so not sure what to do now…
        It s been many month.

  3. Pingback: How to Migrate from HTTP to HTTPS - Complete Tutorial - Learn SEO
  4. How does one do Step 3 with WPEngine hosting where you don’t have direct access to the MaxCDN account? Is there a way to find the CDN name without it?

  5. I’m following this and your other guide related to WPEngine. I assume there’s no way to do Step 2 if using WPEngine because there’s no direct access to the CDN?

  6. Pingback: Why Your Website Speed Matters and How To Improve It
  7. Hello Brian,
    Thanks for sharing this tutorial, I am facing pblm at sitemap step, my images are not showing under cdn custom domain. Need your help, please

    Tried all the steps as you mentioned.


      • Yes, applied as you mentioned, but images location is not changing. Like on
        It is still the same as before CDN. :(

        • Couple questions… first, are you using Yoast SEO to build sitemaps? That is required. 2nd you might try unchecking the sitemap, saving… then going back in and checking and saving again. This will rebuild the sitemap. Make sure to clear your cache.

  8. Hello Brian,
    I implemented custom function as you mentioned, completed all the steps but images location is not changing in the sitemap. like “” , it is still pointing to the hosting location. (web hosting)

    • Couple questions… first, are you using Yoast SEO to build sitemaps? That is required. 2nd you might try unchecking the sitemap, saving… then going back in and checking and saving again. This will rebuild the sitemap. Make sure to clear your cache, etc.

  9. Having the same issue as others here with Step 8. Have inserted the code into my functions.php, adjusted the domain name, but the new CDN subdomain isn’t reflected in the sitemap–the images are still listed at the origin server rather than the CDN.

    • Couple questions… first, are you using Yoast SEO to build sitemaps? That is required. 2nd you might try unchecking the sitemap, saving… then going back in and checking and saving again. This will rebuild the sitemap. Make sure to clear your cache, etc.

      • Yes, Yoast SEO. And yes, tried unchecking the sitemap option, saving the option, then re-enabling it. Also deactivated the plugin and reactivated it. Have purged host (Kinsta) cache and cleared browser cache. Combo is Kinsta, KeyCDN, and Yoast SEO Premium, and the cdn subdomain is working normally in a regular page source–just not in the sitemap.

        • Hey David, this is on your camera website right? My site is also on Kinsta + KeyCDN + Yoast SEO, so we have the same setup. However, on your sitemap, I am looking at the requests and I see “server:cloudflare-nginx.” I’m assuming you are running KeyCDN in combination with CloudFlare? That works fine, but perhaps you need to try purge the CloudFlare cache?

          • Yeah, tried that too, and putting Cloudflare in development mode, and disabling Cloudflare completely, but still no luck. I’ll keep digging–thanks for your help.

  10. Is there a way to make Step 7 to work with multiple domains in multisite setups where more than one domain uses the same functions.php file?

  11. Hi Brian. Do I really need to perform step-2 above? It should pick it up default robots.txt file.. right?

  12. Hi Brian. Do I really need to perform step-2 above? It should pick it up default robots.txt file.. right? Could you confirm?

    • Yes. Technically you shouldn’t have to do #2. Because even the allow directive in my CDN robots shouldn’t be needed. Allowed is usually unnecessary, as if you don’t specify it will already be crawl-able. I have used the method above with other CDN providers as well and it works great. Images re-index every time :) Give it a few days, but you will see them come back.

      • Yeah. Thanks. out of 2165 images currently only 1 image is indexed.. Let’s wait for few days, will update.

        • Cool ya even in my pics above you can see you should probably wait 4-5 days. And if for some reason it doesn’t work, add the robots on CDN as I showed above. You shouldn’t have to, but currently all my sites have robots enabled with above rules on CDN.

  13. Hi Brian,

    We recently moved to getFlywheel hosting for WP and we have the same issue. Only 2 of our images are indexing. I have been in touch with their support and forwarded them this article and they said that they have done all the parts they should do on the MaxCDN, which they own, and I went on and applied the code as you advised and made sure Yoast SEO sitemap is pointing to the right direction on their images.

    The only thing I haven’t done is adding the URL to my webmasters, as I can’t do that my self and not sure if they done it.

    However I reindexed the sitemap on the 28th and today google picked it up, but still only 2 images appear. My only concern is that their CDN url is still picked up as a blocked resource.

    Can you offer any advise?

    • Hi,
      You don’t need do to the URL in webmaster tools part for it to work. The important part is the Yoast function update and then also making sure canonical is enabled on CDN. You might not have waited long enough. Sometimes I have seen it take 3-4 days for webmaster tools to recognize the change. I work for KeyCDN and we actually have an entire blog post about indexing images: Same applies for MaxCDN.

      I would double check with MaxCDN that the canonical tag is enabled.

      • Hi Brian, unfortunately I do not get to pick the CDN, it is provided by getFlywheel. I will give it a few more days, but the thing I didn’t understand is the canonical part. I haven’t done that on my site; so is it something I should do on the site or is it Flywheel’s job?

        • Well, the canonical part, like in Step 1 above is actually done on the CDN side. Since Flywheel bundles it you can’t login to MaxCDN unfortunately, but those screenshots above are from the MaxCDN dashboard. So since they don’t provide you with login to CDN, it definitely is Flywheel’s job to setup the CDN for you correctly.

          • Brian,
            Top man, I remember they said they did something but I will ask them whether they done the canonical.
            You are so kind and thank you for providing us these information.

  14. Hey Brian,

    Thanks for this. I’ve followed every step and it’s worked up until I edit my functions.php file. I alter the code to include my site and my CDN url, and place the code at the end of my functions.php. Then my site breaks! I’ve tried to work out what I’ve done wrong but I have no idea? Any advice would be appreciated!

  15. Hello, Brian thank you for this article.

    When i have a look at the Yoast SEO Sitemap, it has links to the attachment pages, and not the actual attachments. Based on this I am not sure how adding the code to the functions.php would help.

  16. Hi,
    I’m not sure if you are following up on these old posts, but I could use an advice.
    I tried adding the filter on my functions.php, disabled – saved -enabled – saved xml-sitemaps to force them to update, but the only image paths that became rewritten were the paths to featured images. what could cause this? I’m using WP 4.7.3 and Yoast 4.4.


Leave a Comment