I have a new Drupal 8.0.4 site running on Nginx, and I just noticed that the paths for anonymous users have a superfluous index.php in front of them.

So instead of


I get the following when not logged in


I'm not entirely sure if it was this way since I started building the site, because I was usually logged in I might not have noticed it. But it could also have happened only since I upgraded Drupal core to the latest minor version.

My Nginx configuration is based on the official Nginx recipe for Drupal, with some small differences in the php-fpm configuration for PHP 7.

As mentioned in the comment by Sachbearbeiter, this seems to be an intermittent issue. I don't see it anymore now on my site, some days later.

Any idea what is causing the index.php to be inserted and how I can get rid of it at all times?

  • Interesting - i have the same problem from time to time ... After clearing the cache multiple times it disappears ... – Sachbearbeiter Mar 1 '16 at 9:02

To me this is happening when using path ‹front› which is used in block--system-branding-block.html.twig. I just fixed it like this:


{{ path('‹front›') }}


{{ path('‹front›')|replace({'index.php/': ''}) }}

This is mainly an SEO issue. Search engines seem to like unclean URLs with index.php. Once they found one all internal links on your site also contain index.php and so they sometimes crawl the entire site in this namespace.

You have to return a 301 redirect for any unclean URL to stop this. Install the module Redirect and go to the module settings /admin/config/search/redirect/settings:


[x] Enforce clean and canonical URLs.

Enabling this will automatically redirect to the canonical URL of any page. That includes redirecting to an alias if existing, removing trailing slashes, ensure the language prefix is set and similar clean-up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.