Symfony 2 Assetic css and js 404 within production environment
Hi I think you are having issues because of cssrewrite.
You have two options;
Specify output directory
Point your files manually and use cssrewrite filter in twig. See here; http://symfony.com/doc/current/cookbook/assetic/asset_management.html#fixing-css-paths-with-the-cssrewrite-filter
This is an example of the first option
You can specify an output directory for your assets. The example below points to '/web/bundles/yourbundle/css' Do an assets:install --env=prod
and assetic:dump --env=prod
and I think you are good to go.
{% stylesheets'@admin_css'output='bundles/yourbundle/css/admin_style.css'%}<link href="{{ asset_url }}?{{ AssetVersion }}" rel="stylesheet" type="text/css">{% endstylesheets %}
Also I have to mention that when you define your assets in asset.yml, assetic:dump
generates an assets
folder in your public assets directory, which you don't need in this case. To get rid of that folder you can use this syntax in twig;
{% stylesheets'@YourBundle/Resources/public/css/admin.css'output='bundles/yourbundle/css/admin_style.css'%}<link href="{{ asset_url }}?{{ AssetVersion }}" rel="stylesheet" type="text/css">{% endstylesheets %}