unit
unit copied to clipboard
PHP: Routes uri match and trailing slash
I'm configuring a route as follow for a php application:
{ "app2" : [ { "match":{ "uri": ["/test/*"], "method": "GET" }, "action":{ "pass": "applications/app2" } } ] }
with a basic listener:
"listeners": { "*:8080": { "pass": "routes/app2" } },
Accessing route by browser i can test correctly the application by the following address http://SERVER_IP:8080/test/ Is it possible to avoid trailing slash in the address (ex http://SERVER_IP:8080/test)? I tried changing the uri match from "uri": ["/test*"], to "uri": ["/test*"] but the result is the same: Error 503.
Thanks in advance.
Can you please share the unit.log as well as the whole unit configuration? That will help to trace down the issue. Thanks
Hi @lucatacconi
I suggest testing pure matching first. For example:
{
"listeners": {
"*:8080": {
"pass": "routes"
}
},
"routes": [
{
"match": {
"uri": "/test*"
},
"action": {
"return": 206
}
}
]
}
If it doesn't match, it will return 404. I just tested and it works. If it returns 503, it shows that the route is matched, but the application doesn't work, you need to check its service.
@lucatacconi Could you test this patch? It should allow you to access the URL without a trailing '/'.
You can test it with your original config with the match as "/test*".
The fix for this has been merged. a032744