title: Symfony 3 environment driven by url - 404 on _wdt and _profile
body: <p>I would like to drive my environment (dev, prod) by URL</p>
  
  <pre><code>myuser.ENV.domain (eg : foo.dev.test.com or foo.prod.test.com)
  </code></pre>
  
  <p>So I decide to do some changes in .htaccess file</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 %{SERVER_NAME} mydevserver.priv?$
      RewriteCond %{HTTP_HOST} ^(.+)\.(.+)\.(mydevserver.priv)?(:80)?$
      RewriteRule .* - [E=SF_USER:%1,E=SF_ENV:%2,E=SF_SERVER:%3,QSA,L]
  
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ %{ENV:BASE}/app.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Next, I do some changes in app.php</p>
  
  <pre><code>&lt;?php
  
  ini_set('memory_limit', '256M');
  umask(0000);
  
  use Symfony\Component\Debug\Debug;
  use Symfony\Component\HttpFoundation\Request;
  
  $env = filter_input(INPUT_SERVER, 'SF_ENV') ?: $_SERVER['SF_ENV'];
  
  /** @var \Composer\Autoload\ClassLoader $loader */
  $loader = require __DIR__ . '/../app/autoload.php';
  
  if ('dev' === $env) {
      $debug = true;
      Debug::enable();
  } elseif ('prod' === $env) {
      include_once __DIR__ . '/../var/bootstrap.php.cache';
      $debug = false;
  } else {
      throw new \Exception('Environment Not handled');
  }
  
  $kernel = new AppKernel($env, $debug);
  $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 go on the prod URL, I have the default success page of Symfony 3, without debug toolbar.</p>
  
  <p>When I go on the dev URL, I have the default success page but I don't have the debug toolbar. There is a 404 error about _wdt &amp; _profiler routes.</p>
  
  <p>But, If I go on the file app_dev.php, I have the debug tool bar.</p>
  
  <p>I probably miss a little thing but I can't figure out.</p>
  
  <p>I did a fast test renaming app.php into index.php and remove the DirectoryIndex but it changes nothing.</p>
  
  <p>If I user var_dump on my $env var, it gets the good env from environment variable SF_ENV.</p>
  
  <p>Can someone help me ?</p>