php - How to handle trailing slash in nginx? -
i have slim api , app adds slashes @ end of every call. there no way change calls search way remove trailing slashes api calls.
how do this?
this tried:
rewrite ^/api/(.*)/$ /v1/index.php?$args;
you can use middleware this.
use psr\http\message\requestinterface request; use psr\http\message\responseinterface response; $app->add(function (request $request, response $response, callable $next) { $uri = $request->geturi(); $path = $uri->getpath(); if ($path != '/' && substr($path, -1) == '/') { // remove trailing slash $uri = $uri->withpath(substr($path, 0, -1)); $request = $request->withuri($uri); } return $next($request, $response); }); see http://www.slimframework.com/docs/cookbook/route-patterns.html details.
Comments
Post a Comment