I want to redirect a path without an ending slash to slashed version, but I want also to take into account query part. So something like this:
a) /test redir to /test/
b) /test?q=hello redir to /test/?q=hello
A simple
redir /test /test/
only covers (a) case. I can also do
redir /test /test/?{query}
but then (a) case is redirected to /test/? that is not wrong (AFAIK) but is kind of “ugly”.
The implied matcher is a path matcher, not a path+query matcher.
redir /test /test/ will catch a request to /test?query=foo.
If you want to be lazy, you can just redir to /test/?{query}. It’ll add a dangling ? to all unslashed requests, but that’s not exactly a massive issue at all.
Yes, I noticed already that, as stated in my original question, but I was looking for a simpler way of doing it just the way I want (that is, no question mark if no query). More precisely I am looking for a simpler way to match the ‘/test?’ part (with the question mark) on the original URI.
If not, I will just stick to what I already have, as it works correctly
Ahh, you’re right, sorry - I skimmed over the ‘but then (a) case… is kind of “ugly”’ part!
You could probably regexp it to do it in one go, but that’s not very efficient on resources. Your CEL expression is probably the most efficient way to do it.