Redirect loop with "Enforce clean and canonical URLs"

Created on 11 May 2020, over 4 years ago
Updated 6 August 2024, 5 months ago

Have site where lot of parts are made of Angular. For that reason, it was required to use trailing slash before parameter. Like
/search/?query=potato after "/search". This trailing slash is added in code that makes redirect afterward:

if (strpos($request->getUri(), '/search/') === FALSE) {
  // Make sure we load the page with a trailing slash, otherwise the angular app has issues.
  $url = preg_replace('/\/search/', '/search/', $request->getUri());
  return new RedirectResponse($url);
}

but then redirect module redirects it again without trailing slash (/search?query=potato), so it makes a redirect loop.

Not an expert in Angular - something could probably be changed so it works, but in general - this could be also not angular need. Maybe some "exception paths" field be added, so this could be configurable? Currently, the only option was to opt-out "Enforce clean and canonical URLs" checkbox. Other ideas how to pass this redirect so it respects custom modules needs?

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇱🇻Latvia biguzis

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024