SyliusRedirectPlugin icon indicating copy to clipboard operation
SyliusRedirectPlugin copied to clipboard

Redirect with less than 4 characters are not redirected

Open maximehuran opened this issue 1 year ago • 1 comments

Example

Redirect /faq to /en/faq

Will result to a redirect to the homepage because Sylius think faq is a locale

Sylius calls the homepage with default locale in this listener

image

maximehuran avatar Oct 05 '24 14:10 maximehuran

One solution is to replace the regular expression of the locale in config/routes/sylius_shop.yaml so that it doesn't correspond to 4 characters. Example:

     requirements:
-        _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
+        _locale: ^[a-z]{2}(?:_[A-Z]{2})?$

You need to adapt this expression to your project!

delyriand avatar Oct 09 '24 08:10 delyriand