-
|
Hello, I'm wondering how we can achieve trailing slash rewrite in Nginx Unit in case of PHP (Laravel) app? I need to return 301 redirect for all requests that ends with In Nginx it can be achieved with one simple rewrite:
How we can do it in case of Nginx Unit? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
|
This routes array should do what you want [
{
"match": {
"uri": "/*/"
},
"action": {
"rewrite": "`${uri.slice(0,-1)}`",
"return": 301,
"location": "$uri"
}
},
{
"action": {
"return": 204
}
}
] |
Beta Was this translation helpful? Give feedback.
-
|
First of all thank you for super fast reply. I tried this config, but it doesn't work :/ I'm receiving 301 redirect, but with broken URL. |
Beta Was this translation helpful? Give feedback.
This routes array should do what you want
[ { "match": { "uri": "/*/" }, "action": { "rewrite": "`${uri.slice(0,-1)}`", "return": 301, "location": "$uri" } }, { "action": { "return": 204 } } ]