title: Oops! An Error Occurred The server returned a "404 Not Found". Symfony
body: <p>Can someone please enlighten me what causing this problem in symfony and how to solve it.</p>
  
  <blockquote>
    <p>Oops! An Error Occurred  The server returned a "404 Not Found".</p>
  </blockquote>
  
  <p>I'm just new in symfony and cpanel.</p>
  
  <p>I just uploaded my working SF application from my pc (localhost) to my server or <code>CPANEL</code>. CPanel doesn't have <code>SSH access</code> so I used FTP to upload all directories. The directory of the files like so.</p>
  
  <p>home/swipecom</p>
  
  <ul>
  <li>cache</li>
  <li><strong>contactless (Where SF directories live)</strong></li>
  <li><strong>public_html (/web the only SF directory)</strong></li>
  <li>var</li>
  <li>ssl</li>
  <li>tmp</li>
  <li>public_ftp</li>
  <li>logs</li>
  </ul>
  
  <p>I created <code>.htaccess</code> into <code>public_html</code> like so <code>public_html/.htaccess</code></p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      RewriteBase /web
  
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ app.php [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Lastly, I configured <code>app.php</code> in something like this.</p>
  
  <pre><code>&lt;?php
  
  use Symfony\Component\HttpFoundation\Request;
  
  /** @var \Composer\Autoload\ClassLoader $loader */
  
  // $loader = require __DIR__.'/../app/autoload.php';
  // include_once __DIR__.'/../var/bootstrap.php.cache';
  
  $loader = require '/home2/swipecom/contactless/app/autoload.php';
  include_once '/home2/swipecom/contactless/var/bootstrap.php.cache';
  
  $kernel = new AppKernel('prod', false);
  $kernel-&gt;loadClassCache();
  //$kernel = new AppCache($kernel);
  
  // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
  //Request::enableHttpMethodParameterOverride();
  $request = Request::createFromGlobals();
  $response = $kernel-&gt;handle($request);
  $response-&gt;send();
  $kernel-&gt;terminate($request, $response);
  </code></pre>
  
  <p>When I try to access the app like so <code>www.domain.com</code> here's the response I received.</p>
  
  <blockquote>
    <p>Oops! An Error Occurred</p>
    
    <p>The server returned a "404 Not Found".</p>
    
    <p>Something is broken. Please let us know what you were doing when this
    error occurred. We will fix it as soon as possible. Sorry for any
    inconvenience caused.</p>
  </blockquote>
  
  <p><strong>UPDATE</strong></p>
  
  <p>routing.yml</p>
  
  <pre><code>route_frontend:
      resource: "@SwipeBundle/Resources/config/routing_frontend.yml"
  
  route_backend:
      resource: "@SwipeBundle/Resources/config/routing_backend.yml"
  
  route_security:
      resource: "@SwipeBundle/Resources/config/routing_security.yml"
  </code></pre>
  
  <p>routing_dev.yml</p>
  
  <pre><code>_wdt:
      resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
      prefix:   /_wdt
  
  _profiler:
      resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
      prefix:   /_profiler
  
  _errors:
      resource: "@TwigBundle/Resources/config/routing/errors.xml"
      prefix:   /_error
  
  _main:
      resource: routing.yml
  </code></pre>
  
  <p>AppKernel.php</p>
  
  <pre><code>class AppKernel extends Kernel
  {
      public function registerBundles()
      {
          $bundles = [
              new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
              new Symfony\Bundle\SecurityBundle\SecurityBundle(),
              new Symfony\Bundle\TwigBundle\TwigBundle(),
              new Symfony\Bundle\MonologBundle\MonologBundle(),
              new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
              new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
              new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
              //  new SunCat\MobileDetectBundle\MobileDetectBundle(),
              new SwipeBundle\SwipeBundle(),
          ];
  
          if (in_array($this-&gt;getEnvironment(), ['dev', 'test'], true)) {
              $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
              $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
              $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
              $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
          }
  
          return $bundles;
      }
  
      public function getRootDir()
      {
          return __DIR__;
      }
  
      public function getCacheDir()
      {
          return dirname(__DIR__).'/var/cache/'.$this-&gt;getEnvironment();
      }
  
      public function getLogDir()
      {
          return dirname(__DIR__).'/var/logs';
      }
  
      public function registerContainerConfiguration(LoaderInterface $loader)
      {
          $loader-&gt;load($this-&gt;getRootDir().'/config/config_'.$this-&gt;getEnvironment().'.yml');
      }
  }
  </code></pre>
  
  <p><code>.htaccess</code> inside <code>web</code> directory</p>
  
  <pre><code>DirectoryIndex app.php
  
  &lt;IfModule mod_negotiation.c&gt;
      Options -MultiViews
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
      RewriteRule ^(.*) - [E=BASE:%1]
  
      RewriteCond %{HTTP:Authorization} .
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  
      RewriteCond %{ENV:REDIRECT_STATUS} ^$
      RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule .? - [L]
  
      RewriteRule .? %{ENV:BASE}/app.php [L]
  &lt;/IfModule&gt;
  
  &lt;IfModule !mod_rewrite.c&gt;
     &lt;IfModule mod_alias.c&gt;
         RedirectMatch 302 ^/$ /app.php/
     &lt;/IfModule&gt;
  &lt;/IfModule&gt;
  </code></pre>