Setono / SyliusRedirectPlugin

Add redirects to your Sylius store from a simple interface
MIT License
22 stars 24 forks source link

Redirect with less than 4 characters are not redirected #120

Open maximehuran opened 3 weeks ago

maximehuran commented 3 weeks ago

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

delyriand commented 3 weeks ago

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!