Controller/RedirectingController.php
public function removeTrailingSlashAction(Request $request)
    {
        $pathInfo   = $request->getPathInfo();
        $requestUri = $request->getRequestUri();
        
        $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);
        
        return $this->redirect($url, 301);
    }
public function removeTrailingSlashAction(Request $request)
    {
        $pathInfo   = $request->getPathInfo();
        $requestUri = $request->getRequestUri();
        
        $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);
        
        return $this->redirect($url, 301);
    }
public function removeTrailingSlashAction ( Request $ request ) { $ pathInfo = $ request -> getPathInfo ( ) ; $ requestUri = $ request -> getRequestUri ( ) ; $ url = str_replace ( $ pathInfo , rtrim ( $ pathInfo , ' /' ) , $ requestUri ) ; return $ this -> redirect ( $ url , 301 ) ; }
Action used to remove trailing slash in url

@param Request $request

@return \Symfony\Component\HttpFoundation\RedirectResponse
Action used to remove trailing slash in url