We are in the process of migrating a Drupal site to Pantheon. The site uses about 55 rewrites and redirects rules in its pre-migration NGINX configuration. Most of them (32) include widlcards (eg. ^/something/(.*)
redirects to /something-else/
) and an handful even keep the matching substring into the redirect-to URL (eg. ^/another/one/(.*)$
redirects to /something/else/$1
).
Pantheon does not support redirects at the web-server levels and suggests doing redirects in the settings.php
(to avoid boostraping Drupal). But 55 redirects seems enough to start worry about maintainability of a bunch of if
blocks. There is also the performance cost of 32 pattern matching for each request. So a little care has to be taken to avoid maintenance nightmare in the future.
I'm not too worried about performances since the site is mostly cached anonymous traffic. But in addition to requiring a full bootstrap, the Redirect module (already used on the site) is not an option as it does not support wildcards.
I'm toying with the idea of crafting something with nikic/FastRoute to be used from settings.php
. But this seems a bit overkill for 55 redirects.
I'm curious what options have been used on other sites with similar requirements.