Symfony 2 set background image using CSS
You should store your images in the bundle folder.
src/MyBundle/Resources/public/images
and your css in
src/MyBundle/Resources/public/css
since only web folder is accesible from outside you should use the command
app/console assets:install web --symlink
this will now create the links for the web folder as
web/bundles/Project_name/cssweb/bundles/Project_name/images
So your relative path for the image would be as
.header{ background-image: url("../images/mainlogo.gif");}
And in twig you should use asset() function to link your styles:
<link href="{{ asset('bundles/acmeweb/css/yourstylesheet.css') }}" rel="stylesheet" type="text/css" />
you can find complete documentation here