Search code examples
netlify

Why Netlify redirects "/index" to "/" when "index.html" exists (no custom rules defined)


We host our website with Netlify. We have no redirect rules set on our side.

When accessing a url which ends in "index" (for example "animals.com/cats/index") (assuming there is the real index.html page there) Netlify will do a 301 redirect, retrieve index.html, and set the url to the root "animals.com/cats/".

This behaviour is also possible to see in Netlify docs Open "https://docs.netlify.com/routing/headers/index" -> in will redirect to "https://docs.netlify.com/routing/headers/".

Where is this behaviour specified? I can't find anything in their docs.


Solution

  • I contacted Netlify support and they explained how it works.

    There is an option in "Asset optimization" which is when set to "Enable" allows to enable "Pretty URLs".

    With pretty urls there is redirection happening automatically.