title: Symfony: htaccess to hide app.php or app_dev.php
body: <p>I know this has been asked many times, but something strange is happening to me. Apache DocumentRoot is pointing to <em>symfony/web/</em> and this is my .htaccess inside web/ dir:</p>
  
  <pre><code>DirectoryIndex app_dev.php
  #DirectoryIndex app.php
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      RewriteCond %{ENV:REDIRECT_STATUS} ^$
      RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
  
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule .? - [L]
  
  
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule ^(.*)$ app_dev.php [QSA,L]
      #RewriteRule ^(.*)$ app.php [QSA,L]
  
      RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
      RewriteRule ^(.*) - [E=BASE:%1]
      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>
  
  <p>Well, the thing is <code>www.example.com/route1/</code> is working and <code>www.example.com/route2/</code> is throwing an error:</p>
  
  <blockquote>
    <p>Oops! An Error Occurred
    The server returned a "404 Not Found".
    Something is broken. Please e-mail us at [email] and 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>While <code>www.example.com/app_dev.php/route2/</code> is working ok (also  <code>www.example.com/app_dev.php/route1/</code>)</p>
  
  <p>Help?</p>
  
  <p>Update. Cache clear in prod throws this error (I never tried before, I'm working on dev):</p>
  
  <blockquote>
    <p>[Doctrine\Common\Proxy\Exception\UnexpectedValueException]
    The type hint of parameter "userRoles" in method "addRole" in class "MyProject\PanelBundle\Entity\User" is invalid.</p>
    
    <p>[ReflectionException]
    Class Maycol\BlogBundle\Entity\Role does not exist</p>
  </blockquote>