I am looking for way to do this in 'right' symfony way.
Asked
Active
Viewed 1.8k times
1 Answers
9
There's a way to get the referer page from the $request variable. For example, if I was in myaction/mypage and click to myaction2/mypage2 by this getReferer() method I get 'http://myweb/myaction/mypage'.
If you are in an action method this can be done by
public function executeMyaction(sfWebRequest $request)
{
$previousUrl = $request->getReferer();
...
}
if you are somewhere else you can get the request by getting the conext
$previousUrl = $this->getContext()->getRequest()->getReferer();
For for sfWebRequest methods check the sfWebRequest API.
Note: this value could be inaccesible using proxy's

Pabloks
- 1,484
- 1
- 14
- 15
-
4getReferer() will return full request url, but how to get route name of referer url?? – hardik Jan 30 '12 at 09:57
-
1sfWebRequest::getReferer() returns a HTTP_REFERER string not a route corresponding to it. – Ain Tohvri Apr 25 '13 at 10:12