title: Rewrite URLs containing subdirectories to script in root
body: <p>I'm trying to redirect pages in a way that the language indicator, which in the URL is expressed as a subfolder ("en/", "de/" ...), is converted to a parameter I can work with. "FR", as the site's main language, does not have a language subfolder.</p>
  
  <p>To illustrate this:</p>
  
  <pre><code>www.domain/index.html  
  </code></pre>
  
  <p>should redirect to </p>
  
  <pre><code>www.domain/index.php?lang=fr
  </code></pre>
  
  <p>and</p>
  
  <pre><code>www.domain/en/index.html 
  </code></pre>
  
  <p>should redirect to </p>
  
  <pre><code>www.domain/index.php?lang=en
  </code></pre>
  
  <p>I've tried the following in my .htaccess file (which is located in the root directory):</p>
  
  <pre><code>RewriteEngine On
  
  RewriteRule ^en/index\.html$ /index.php?lang=en [L]   
  RewriteRule ^de/index\.html$ /index.php?lang=de [L] 
  RewriteRule ^index\.html$ index.php?lang=fr [L]
  </code></pre>
  
  <p>The last one works as expected, however the first two return a 404. For the second line ("de version"), I get: </p>
  
  <pre><code>The requested URL /de/index.php was not found on this server.
  </code></pre>
  
  <p>Apache logs the following:</p>
  
  <pre><code>[Thu Jul 09 13:14:28 2015] [error] [client ::1] script '/Applications/MAMP/htdocs/testsite/de/index.php' not found or unable to stat
  </code></pre>
  
  <p>It would appear that the first two rules are completely ignored by the server, as changing the target file name in the second line as below:</p>
  
  <pre><code>RewriteRule ^de/index\.html$ /blah.php?lang=de [L]
  </code></pre>
  
  <p>still triggers the same 404 message stating the missing de/index.php and not blah.php ;</p>
  
  <p>What does work however is placing a .htaccess in a subfolder named 'de' and pointing from there to the index.php in the root folder with</p>
  
  <pre><code>RewriteRule ^index\.html$ /index.php?lang=de [L]
  </code></pre>
  
  <p>But that's not a proper solution, is it ?</p>