I know you can redirect from = "/en/category/product/*" to = "/en/c/p/:splat",
but is it also possible to make this dynamic in case you have multiple language?
Something like from = "/:lang/category/product/*" to = "/:lang/c/p/:splat"?
Except for something like from = "/category/product/*" to = "/en/c/p/:splat" condition ={Language = ["en"]}, but that’s not what I want because if I actually want to visit let’s say /nl/category/product/* I will be redirected to /en/nl/c/p/:splat.
The event object contains a property called path which is a string. The path string is converted to an array and then the zero (0) index is the language dynamic path.
The match() method is used to search a string for a match against any regular expression. If the match is found, then this will return the match as an array.
You can console log the variables to get a clear picture of the logic starting with the event object.
This is a hacky solution. I also don’t know your use case but I think it will suffice for most use cases. You can also return an HTML as your response body.