I’m running into an issue with my static site, and I could really use some help. Here’s the situation:
Project Structure:
My project is a simple HTML, CSS, and JS site with the following structure:
/my-site/
├── dist1/
│ └── about-us.html
├── dist2/
│ └── contact.html
├── dist3/
│ └── services.html
├── _redirects
├── netlify.toml
└── index.html
Goal:
I want to force all non-.html URLs to redirect to their .html counterparts, like this:
/dist1/about-us ➔ /dist1/about-us.html (301 Redirect) What I Tried:
Disabled Pretty URLs: I have unchecked the Pretty URLs setting in my Netlify dashboard. Added _redirects File: My _redirects file (located in the project root) contains: /* /:splat.html 301
Added netlify.toml:
I also tried using a netlify.toml file with this configuration:
[[redirects]]
from = “/*”
to = “/:splat.html”
status = 301
force = true
Cleared Cache:
Cleared the build cache in Netlify.
Cleared my Cloudflare cache (I’m using Cloudflare as my DNS provider). The Problem:
Despite all this, my non-.html URLs are still not redirecting. Both of these URLs are returning a 200 OK:
https://example.com/dist1/about-us https://example.com/dist1/about-us.html **What I Checked:
The _redirects and netlify.toml files are in the project root. The build logs don’t show any errors related to the redirects. I’ve cleared both Netlify and Cloudflare caches multiple times. There are no conflicting page rules in Cloudflare. What I Need Help With:
Why is Netlify ignoring my _redirects file and netlify.toml configuration? How can I force the .html redirects to work consistently across my site? Any guidance would be greatly appreciated!
Thanks in advance for your help!