Hey,
my redirects have been behaving weirdly lately and I don’t quite understand what the problem is. For the longest time (4+ years) I used the following _redirects configuration and it worked as expected:
/* /index.html 200
If you request a file lets say /sitemap.xml it would properly display the file and everything else gets redirected to the index.html as you’d expect. But at some point this has changed and Netlify started serving the .html paths even for resources that have a file behind them:
For instance lets take the /sitemap.xml
This serves /index.html, if you refresh a few times it sometimes will display the /sitemap.xml
( Can only embed one image so this one is just a link: https://i.imgur.com/TPwGPB0.png )
In an attempt to solve this I played around with changing the configuration a few times:
In this attempt (whats currently live) I decided to specifiy every route that should go to /index.html separately
/ /index.html 200
/b/* /index.html 200
/favorites /index.html 200
/about /index.html 200
/settings /index.html 200
Combined with this in my netlify.toml
[[redirects]]
from = "/*"
to = "/index.html"
status = 404
So that the 404 pages keep working.
Before that I tried to hard wire the static files I cared about into it:
/robots.txt /robots.txt 200
/sitemap.xml /sitemap.xml 200
/data.json /data.json 200
/meta.json /meta.json 200
/map/names.json /map/names.json 200
/* /index.html 200
Which also resulted in a similar outcome.
Keep in mind that I’m using the live site with Cloudflare, but I’ve been able to reproduce this on deployment previews which are not served through that CDN. So I’m certain this is not the cause of the issue either.
Unless I’m doing something wrong, this seems like an issue on Netlifys end, otherwise I’d at least hope to see a somewhat consistently broken behavior on my end :).
Best regards.