How to include fragment (#) in the URL computed by redirect? I want to redirect the user to an internal path that includes a fragment (the part of the url that is introduced with a #), e.g.:

/comment/19#comment-19


I know how to build the path without the fragment portion. If $cid is the comment id, this will do it:

$this-&gt;redirect($comment-&gt;permalink()-&gt;getRouteName(), array('comment' =&gt; $cid));


But how can I add a fragment to the path?
The fragment is stored in the options of the url, also the cid in the parameters. So you'll find all information you need in the url permalink() returns:

  $url = $comment-&gt;permalink();

  $this-&gt;redirect($url-&gt;getRouteName(), $url-&gt;getRouteParameters(), $url-&gt;getOptions());