I was wondering how can I get the path of the previous url?
May someone enlighten me.
If you want to return the last response (the previous page where you have been) just do this:
return $this->redirect($request->headers->get('referer'));
If you want to get just the path do this:
$request->headers->get('referer');
If you have been e.g. in
www.example.com/a and the you go to www.example.com/a/b
If you call the referer from "B" it will be: www.example.com/a