Controller/Controller.php
protected function redirectToReferer($defaultPath)
    {
        if (null !== $request = $this->get('request_stack')->getCurrentRequest()) {
            if (0 < strlen($referer = $request->headers->get('referer'))) {
                return $this->redirect($referer);
            }
        }
        return $this->redirect($defaultPath);
    }
protected function redirectToReferer($defaultPath)
    {
        if (null !== $request = $this->get('request_stack')->getCurrentRequest()) {
            if (0 < strlen($referer = $request->headers->get('referer'))) {
                return $this->redirect($referer);
            }
        }
        return $this->redirect($defaultPath);
    }
Redirect to the referer.

@param string $defaultPath
@return \Symfony\Component\HttpFoundation\Response