Setting up netlify.toml for pretty url

I believe part of the confusion here is whether or not the ‘Asset optimization - Pretty URLs’ is supposed to apply any redirection of a users request for a file.

My understanding, based on the description written under it, is that it scans and changes your HTML to remove references to URLs ending in .html, so if you had a link of href="/about.html", it would adjust your code to href="/about".

What @luisrieke is questioning is that if a user is directly accessing a file with the .html extension in the URL, a file which does exist, is it possible to redirect them to the Pretty URL for that same file.

Example: Going directly to https://luisrieke.com/running.html loads /running.html and doesn’t redirect to /running

I’m not sure I’ve ever tried, but I imagine due to shadowing any redirect for it would need to include force.

So perhaps the equivalent of:

[[redirects]]
  from = "/running.html"
  to = "/running"
  force = true
2 Likes