I made some migration of pretty old website to d8. And urls ported fine from latest WP version:


But from what I see in google many articles would be linked with index.php at the end i.e.:


etc etc. Somehow WP could handle it (no traces of overrides in htaccess), but Drupal would not.

Puzzled how to fix it with htaccess, preferably with 301 redirect.

Thanks for your ideas!

1 Answer 1


Solved thanks to https://stackoverflow.com/questions/27907044/htaccess-rule-to-remove-index-php-from-the-end-of-my-urls

Modified part of Drupal's .htaccess. Important to add new rule before standard index rewrite:

# Remove trailing /index.php that comes from external links.
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

# Pass all requests not referring directly to files in the filesystem to
# index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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