Redirecting /index.html to root domain doesn't work


I just added my site on Netlify, and everything seems to work well, except for one thing.

I’ve read a bunch of similar topics but didn’t help.

I have a very simple static website created with Bootstrap - No site generators, build commands; nothing.

My files aren’t in a public, src, or similar folders. The index.html file is directly in the root, along with the netlify.toml file.

The issue

Currently, the homepage is also accessible via /index.html, creating a duplicate. Even if I have a canonical URL set, I prefer redirecting it to the root /.

So, I added this to the netlify.toml file:

    from = "/index.html"
    to = "/"
    status = 301
    force = false

But it doesn’t work.

I also tried:

  • _redirects file;
  • adding force = true;
  • adding the full home URL in to.

I have other things in the file that work fine:

  from = "*"
  to = ""
  status = 301
  force = true

    for = "/*"
        X-Frame-Options = "DENY"
        X-XSS-Protection = "1; mode=block"

So, the placement of the file is not an issue. Either I’m adding the redirection code wrong, or it’s not possible to perform that type of redirect.

Any help would be appreciated!


@RaduB Welcome to the Netlify community.

Part of the problem is that there is no file at your root. The file that is served is index.html. If you redirect away from that file to no file, no file will be served. That’s the way it works.

If you want it LOOK as if the index.html is not being served, then try turning on Pretty URLs under Asset Optimization in the Build and Deploy section of the site Dashboard on Netlify.

1 Like


Got it! Thanks!