Sign in

Index.html not redirecting to root

  • This topic has 3 replies, 3 voices, and was last updated 1 week, 2 days ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7693
    ritesh

    Hi,

    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:

    [[redirects]]
    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?

    #7694
    deepvyas

    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} !^www.yourdomainname.com
    RewriteRule . index.php [L]
    </IfModule>

    #7696
    ritesh

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

    #7896
    Tomasz Dziuda

    Hi,

    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:

    /post-slug/

    /post-slug/index.html

    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:

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

     

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.