I use Page Rules to 1:1 redirect a whole domain to a new one (on which I have Cloudflare as well)
While all redirects work fine, sometimes the redirects of some images return a 404 on the new domain, although the images exist on the new address and have the exact same path.
Like I enter old.example.com/images/image-1.jpg, it shows that it 301 redirect to the new domain address new.example.com/images/image-1.jpg but then it returns a 404 like the image don’t exist on the new domain (through it exist). This mostly happens on the first check, if I do another check with the same URLs, it works fine and the redirect returns 200 on the new address.
*This happens only with images
I asked someone who is more knowledge with this stuff and advised me to check with Cloudflare. He said " If CF does not know yet that the image exists under the new URL, it’ll respond with a 404. That it gets it right on the second request, probably means that the 404 triggered some sort of cache update after the fact".
How do I resolve this issue? Is Cloudflare related?
Page Rules require a "proxied" DNS record for your page rule to work. Page Rules won't apply to hostnames that don't exist in DNS or aren't being directed to Cloudflare.
If you need further assistance, share the example of your existing rule.
The page rules actually work (the old URL redirects to the new one) but sometimes once the redirect is done it returns a 404 on the new address, instead of 200.
This only happens with images. Could be caused by a cache issue or?
I don’t understand why this is happening since the image exist on the new domain and has the exact same path/URL as the redirected URL. So the request returns a 301 and then sends to the new location (new domain, same path) which returns a 404 and then I refresh the page (with the exact URL that previously returned a 404) and finally the image appear.