nystudio107 / craft-retour

Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website
https://nystudio107.com/plugins/retour
Other
38 stars 26 forks source link

Regex Redirect not working as expected #283

Closed CreateSean closed 1 year ago

CreateSean commented 1 year ago

Craft CMS 4.4.15.6 Retour

Question

I'm trying to redirect anything with a url pattern of /glossary-terms/any-slug/ and have set up the legacy pattern like this \/glossary-terms\/[a-zA-Z0-9\-]+\/ with match type of path only and regex match.

but it's not working as expected. Please advise. I suspect this is user error on my part but cannot figure it out.

Additional context

Add any other context or screenshots about the support request here.

khalwat commented 1 year ago

Can you tell me what is not working as expected?

Did you test the RegEx here:

https://regexr.com/

Retour isn't doing anything special or custom here, it's just a standard PHP regex match.

CreateSean commented 1 year ago

@khalwat New validated and confirmed working from regexr you provided is ^glossary-terms\/[a-z0-9]+(?:(?:-|_)+[a-z0-9]+)*$

but when I add that to retour and visit a url that I expect to redirect to the homepage it still returns a 404

image

khalwat commented 1 year ago

Give me an example of a URL that you think should work, but does not.

Also, I think you might be overcomplicating your RegEx a bit there

CreateSean commented 1 year ago

/glossary-terms/any-slug

khalwat commented 1 year ago

https://regexr.com/7k1bt