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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -