Requirement-
I want to redirect all requests that end with /abcd
to /products/abcd
This should match all urls such as these-
- /collection/abcd
- /collections/all/abcd
- /hello/world/abcd
This is what i'm using-
rewrite /abcd/?$ https://example.com/products/abcd permanent;
The problem- if someone visits /products/abcd
, this url also matches the rewrite rule, and goes into an infinite loop.
I also tried this regex, but that doesn't match any url (i.e. no redirects happen)- rewrite /(^products/)abcd/?$ https://example.com/products/abcd permanent;