We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Index.html not redirecting to root

  • #7693
    Avatar photo[anonymous]


    I’m using Netlify.

    Currently, all the pages on the site are accessible with and without index.html at the end of the URL.

    I turned on pretty URLs, but that didn’t work.

    I then added this code:

    from = "/*/index.html"
    to = "/:splat:"
    status = 200
    force = false

    Even that’s not working. If I add true to force, it shows a 404 error, but it won’t strip index.html off of the URLs.

    What should I do?

    Avatar photo[anonymous]

    Hope this .htaccess rule may solve your problem

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}/index.html !-f
    RewriteCond %{REQUEST_FILENAME}/index.php !-f
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^
    RewriteRule . index.php [L]

    Avatar photo[anonymous]

    Hey, thanks for the snippet. I’ve tried it, but unfortunately, it didn’t work.

    Avatar photo[anonymous]


    It is due nature of static websites – even if you are using pretty URLs, Publii will generate directory where index.html exists – so both URLs will work:



    Unfortunately the only way to handle this is server configuration which will redirect index.html to the directory path.

    .htaccess won’t work on Netlify, in fact it seems to be problematic to achieve on Netlify, maybe please try such config:

      from = "/:slug/index.html"
      to = "/:slug/"
      status = 200
      force = false