title: Path of assets in CSS files in Symfony 2
body: <h3>Problem</h3>
  <p>I have a <a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets" rel="noreferrer">CSS</a> file with some paths in it (for images, fonts, etc.. <code>url(..)</code>).</p>
  <p>My path structure is like this:</p>
  <pre><code>...
  +-src/
  | +-MyCompany/
  |   +-MyBundle/
  |     +-Resources/
  |       +-assets/
  |         +-css/
  |           +-stylesheets...
  +-web/
  | +-images/
  |   +-images...
  ...
  </code></pre>
  <p>I want to reference my images in the stylesheet.</p>
  <h3>First Solution</h3>
  <p>I changed all paths in the CSS file to absolute paths. This is no solution, as the application should (and has to!) be working in a subdirectory, too.</p>
  <h3>Second Solution</h3>
  <p>Use Assetic with <code>filter=&quot;cssrewrite&quot;</code>.</p>
  <p>So I changed all my paths in my CSS file to</p>
  <pre><code>url(&quot;../../../../../../web/images/myimage.png&quot;)
  </code></pre>
  <p>to represent the actual path from my resources directory to the <code>/web/images</code> directory. This does not work, since cssrewrite produces the following code:</p>
  <pre><code>url(&quot;../../Resources/assets/&quot;)
  </code></pre>
  <p>which is obviously the wrong path.</p>
  <p>After <code>assetic:dump</code> this path is created, which is still wrong:</p>
  <pre><code>url(&quot;../../../web/images/myimage.png&quot;)
  </code></pre>
  <p>The twig code of Assetic:</p>
  <pre><code>{% stylesheets
      '@MyCompanyMyBundle/Resources/assets/css/*.css'
      filter=&quot;cssrewrite&quot;
  %}
  &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ asset_url }}&quot; /&gt;
  {% endstylesheets %}
  </code></pre>
  <h3>Current (Third) Solution</h3>
  <p>Since all CSS files end up in <code>/web/css/stylexyz.css</code>, I changed all paths in the CSS file to be relative:</p>
  <pre><code>url(&quot;../images/myimage.png&quot;)
  </code></pre>
  <p>This (bad) solution works, except in the <code>dev</code> environment:
  The CSS path is <code>/app_dev.php/css/stylexyz.css</code> and therefore the image path resulting from this is <code>/app_dev.php/images/myimage.png</code>, which results in a <code>NotFoundHttpException</code>.</p>
  <p>Is there a better and working solution?</p>