Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriting requests to /index.php on drupal sites #90

Open
tylmc3 opened this issue May 3, 2024 · 1 comment
Open

Rewriting requests to /index.php on drupal sites #90

tylmc3 opened this issue May 3, 2024 · 1 comment

Comments

@tylmc3
Copy link

tylmc3 commented May 3, 2024

Hi,

A long-standing Drupal core issue exists surrounding hitting a Drupal site with the URL example.com/index.php which will cache all links on the page with /index.php before the rest of the route.

See index.php randomly appears in friendly URLs and index.php is inserted in menu links

This can be replicated by clearing the caches on a Drupal site, and then navigating to /index.php. Every URL on the page will now have /index.php prefixed to it and when you navigate back to the URL / those cached URLs will persist.

This doesn't cause issues with basic page navigation but will render public and private files inaccessible.

In the issue, [index.php randomly appears in friendly URLs](index.php randomly appears in friendly URLs), a patch exists for the .htaccess to add the RewriteRule RewriteRule ^index\.php/(.*) /$1 [L,R=301] which removes the /index.php from all requests if it exists.

I've modified this .htaccess RewriteRule to work for a site of ours that was affected by this by creating an nginx-override.conf file with the contents

if ($request_uri ~* "^/index\.php(/)?(.*)") {
  rewrite ^/index\.php(/)?(.*) /$2 redirect;
}

With this being a core bug since 2016, with consideration to what other effects this could have, I think adding this to the default Drupal nginx rules would be a good step forward to mitigating this issue in other Drupal sites on the Wodby stack.

@csandanov
Copy link
Member

Hi, thank you. I see they now have a PR pending https://git.drupalcode.org/project/drupal/-/merge_requests/7995/diffs?commit_id=5a73e7d2b422e5278388d665b9592d023447479f. I suggest we wait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants