title: Failed to load assets when deploying symfony on web server: assets are not imported, failed to load resource error 404
body: <p>I am trying to deploy a symfony application for production test. I follow many steps that I am going to explain:</p>
  
  <ol>
  <li><p>First, I have installed the <a href="https://github.com/CoreSphere/ConsoleBundle" rel="nofollow">CoreSphereConsoleBundle</a>, in order to have a browser console. In my local configuration (windows 7 and wamp server apache), when I would like to use her I write this url <code>C:\wamp\www\myApp\app_web.php\_console</code>. It works well. But in my <strong>OVH</strong> <em>shared</em> server, it not works at all when I write <code>www.mydomain.com/web/_console</code>(I don't understand why !).</p></li>
  <li><p>Then I follow the step of the symfony doc; e-g I cleared the cache <code>php app/console cache:clear</code>, and also for the prod environement with <code>php app/console cache:clear --env=prod</code></p></li>
  <li><p>I allow the debug mode.</p></li>
  </ol>
  
  <p><code>\web\app.php</code>:</p>
  
  <pre><code>&lt;?php
  // web/app.php
  
  // …
  
  $kernel = new AppKernel('prod', true); // set the 2nd argument to true
  </code></pre>
  
  <ol start="4">
  <li>I check the compatibility server:</li>
  </ol>
  
  <p><code>web/config.php</code>:</p>
  
  <pre><code>/*if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
  ))) {
    header('HTTP/1.0 403 Forbidden');
    exit('This script is only accessible from localhost.');
  }*/
  </code></pre>
  
  <p>So when I display the url <code>www.mydomain.com/web/config.php</code> I have well the config page with no error.
  And of course, after I allow my own <code>IP adress</code> and I allowed the <code>cache</code> and <code>logs</code> folders to <code>chmod 777</code> too.</p>
  
  <ol start="5">
  <li>I edit my <code>.htaccess</code> <strong>files</strong>. I have two htacess files, one in the root of my server and another in the web folder.</li>
  </ol>
  
  <p><code>/.htaccess</code> (root server)</p>
  
  <pre><code>SetEnv SHORT_OPEN_TAGS 0
  SetEnv REGISTER_GLOBALS 0
  SetEnv MAGIC_QUOTES 0
  SetEnv SESSION_AUTOSTART 0
  SetEnv ZEND_OPTIMIZER 1
  SetEnv PHP_VER 5_4_11
  AddType x-mapp-php5 .php
  
  RewriteEngine on
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ web/app.php [QSA,L]
  </code></pre>
  
  <p><code>/web/.htaccess</code> (web folder):</p>
  
  <pre><code>SetEnv SHORT_OPEN_TAGS 0
  SetEnv REGISTER_GLOBALS 0
  SetEnv MAGIC_QUOTES 0
  SetEnv SESSION_AUTOSTART 0
  SetEnv ZEND_OPTIMIZER 1
  SetEnv PHP_VER 5_4_11
  AddType x-mapp-php5 .php
  
  RewriteEngine On
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ app.php [QSA,L]
  </code></pre>
  
  <ol start="6">
  <li>I make all config I need for the framework (database config with doctrine for my server, framework config etc).</li>
  </ol>
  
  <p>All works well, e-g my application are deploying and displaying when I am going to the homepage. But my <strong>assets</strong> are <strong>not loaded</strong>. Indeed, my <code>css files</code>, <code>js files</code> or <code>images</code> etc <strong>are not imported</strong>.</p>
  
  <p><strong>Where have I made mistakes when I have deployed the symfony application?</strong></p>
  
  <p>I think I have to install the assets on the server, but I have no access to the <strong>CoreSphereConsoleBundle</strong> <code>console</code>, and notice that I have a shared server not a <strong>dedicated Server</strong>.
  On the main page, my browser native console (google chrome) displayed the rrors for each script, css files and other client needles:</p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 404
    (Not Found)</p>
  </blockquote>
  
  <p>I imported my assets correctly in my application, and in my local configuration it works:</p>
  
  <p><code>layout.html.twig</code>:</p>
  
  <pre><code>{% block script %}
    &lt;script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"&gt;&lt;/script&gt;
    &lt;script src="{{ path('fos_js_routing_js', {'callback': 'fos.Router.setData'}) }}"&gt;&lt;/script&gt;
    {% javascripts
      '@MySpaceMyBundle/Resources/public/js/jquery-2.1.3.min.js'
      '@MySpaceMyBundle/Resources/public/js/bootstrap.min.js'
      '@MySpaceMyBundle/Resources/public/js/hinclude.min.js'
      ...
      'http://code.highcharts.com/stock/highstock.js'%}
      &lt;script type="text/javascript" src="{{ asset_url }}"&gt;&lt;/script&gt;
    {% endjavascripts %}
  {% endblock %}
  
  {% block stylesheets %}
    &lt;link rel="stylesheet" href="{{ asset('bundles/MySpaceMyBundle/css/bootstrap-theme.min.css') }}" type="text/css" media="all"/&gt;
    &lt;link rel="stylesheet" href="{{ asset('bundles/MySpaceMyBundle/css/bootstrap.min.css') }}" type="text/css" media="all"/&gt;
    ...
    {# animate CSS #}
    &lt;link rel="stylesheet" href="{{ asset('bundles/MySpaceMyBundle/css/animate.min.css') }}" type="text/css" media="all"/&gt;
    {# dataTables CSS #}
  {% endblock %}
  </code></pre>