title: Symfony 2 routing: UrlGenerator generates wrong relative urls
body: <p>I'm using the <code>Symfony2</code> components with the <code>Symfony2</code> routing component.
  My routes.yml includes another specific sub-app-routes.yml:</p>
  
  <pre><code>subapp:
      resource: "etc/subapp_routes.yml"
      prefix: /subapp
  </code></pre>
  
  <p>The sub-app-routes.yml has the entries:</p>
  
  <pre><code>subapp_calculations_list:
  pattern: /calculations
  defaults:     { _controller: 'My\Project\Controller\Subapp\Calculations::listAction' }
  requirements:
      _method: GET
  
  subapp_calculations_result:
  pattern: /calculation/{id}/result
  defaults:     { _controller: 'My\Project\Controller\Subapp\Calculations::resultAction' }
  requirements:
      _method: GET
  </code></pre>
  
  <p>...which works quite well so far.</p>
  
  <p>Then, I'm using the <code>Symfony\Component\Routing\Generator\UrlGenerator</code> to generate a url from the subapp_routes.yml:</p>
  
  <pre><code>        $requestContext = new RequestContext($_SERVER['REQUEST_URI']);
  
          $router = new Router(
              new YamlFileLoader(new FileLocator(array('.'))),
              "etc/routes.yml",
              array(),
              $requestContext
          );
  
          $this-&gt;urlGenerator = new UrlGenerator($router-&gt;getRouteCollection(), $requestContext);
  </code></pre>
  
  <p>[...]</p>
  
  <pre><code>    public function getRoute($route, $vars = array()) {
          return $this-&gt;urlGenerator-&gt;generate($route, $vars);
  }
  </code></pre>
  
  <p>And in the (php)template:</p>
  
  <pre><code>&lt;a href="&lt;?= $this-&gt;getRoute('subapp_calculations_result', array('id' =&gt; $job['job_id'])) ?&gt;"&gt;
  </code></pre>
  
  <p>But it always returns the current path concatenated with the absolute path of the generated url. </p>
  
  <p>Example:
  I'm at</p>
  
  <pre><code>(http://) project/subapp/calculations
  </code></pre>
  
  <p>I'm generating within the template the url for something located at </p>
  
  <pre><code>(http://) project/subapp/calculations/123/results 
  </code></pre>
  
  <p>Then the url generator returns</p>
  
  <pre><code>(http://) project/subapp/calculations/subapp/calculations/123/results 
  </code></pre>
  
  <p>...which is of course wrong. </p>
  
  <p>I've also tried to change the <code>ABSOLUTE_PATH</code> to <code>ABSOLUTE_URL</code> which is the same just with the hostname at the first part.</p>
  
  <p>Some ideas why <code>symfony 2</code> generates so strange urls? </p>