Is it possible to specify a custom default document?

My goal is to serve up a custom default document for each directory.

I can accomplish this with 301 redirects, but that also changes the url, and I’m trying to maintain friendly urls while serving up a different default document

For example, on the linked site, I can browse to index.html and default.html explicitly:

https://netlify-redirect-test.netlify.app/index.html
https://netlify-redirect-test.netlify.app/default.html

What I’d like is when browsing to the root…

https://netlify-redirect-test.netlify.app/

… to serve up the contents from default.html instead of index.html without changing the URL in the browser

Repo: https://github.com/KyleMit/netlify-redirect-test
Site: https://netlify-redirect-test.netlify.app/

One missing piece was just accomplishing a URL Rewrite by using the appropriate status code.

According to the docs on Routing > Redirect Options > HTTP Status Codes:

  • 301 : “Permanent redirect”. Tells the client that the address for this resource has permanently changed, and any indexes using the old address should start using the new one. The URL in the browser address bar will display the new address.
  • 200 : “OK”. Redirects with this status code will change the server response without changing the URL in the browser address bar. This is used for rewrites and proxying.

And the docs on rewrites and proxying further clarifies:

When you assign an HTTP status code of 200 to a redirect rule, it becomes a rewrite . This means that the URL in the visitor’s address bar remains the same, while Netlify’s servers fetch the new location behind the scenes.

So the following netlify.toml configuration should work at the root level:

[[redirects]]
  from = "/"
  to = "/default.html"
  force = true
  status = 200

However, I can’t find a way to easily apply to all sub folder level directories without breaking the redirects engine:

So the following won’t work:

[[redirects]]
  from = "*/"
  to = ":splat/default.html"
  force = true
  status = 200

Where my intention is to only catch bare folder urls and with */, however, the asterisk seems to catch all URLS and will continue recursively building a path until it throws an exception

@KyleMit, have you tried placeholders? Not sure if they will work for what you need but perhaps close.