title: mod_rewrite .htaccess causing 500 server error if URl does not exist
body: <p>I've just started using mod_rewrite, this is what I use for a quite basic structured website with multiple language support:</p>
  
  <pre><code>RewriteEngine on
  ErrorDocument 404 /error404.php
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([a-zA-Z]{2})/([^/]+)$ $2.php?lang=$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([a-zA-Z]{2})/$ index.php?lang=$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([a-zA-Z]{2})$ index.php?lang=$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)$ $1.php [L]
  </code></pre>
  
  <p>My idea was that languages are indicated at the beginning of the URl and need to be two characters (a-z or A-Z). After that there will be a string that refers to a php-file which has the same filename as the string, just .php attached. The language will be added as a GET-Variable (<code>?lang=en</code>).</p>
  
  <p>So, an URl could look like this: <code>/en/index</code> and should then be redirected to <code>index.php?lang=en</code>.</p>
  
  <p>If the URl does not start with a language, but directly with the string, then no GET-variable will be attached to the string. E.g. <code>/index</code> should refer to <code>index.php</code>. If there is no string, then index should be used as default.</p>
  
  <p>So far, so good. Works fine. Just if I enter a string (no matter if I use 2 characters for language or not), the site always shows an 500 Internal Server Error, instead of going to <code>error404.php</code>. Also, if I delete this line (404) in .htaccess, it is still the same error.</p>
  
  <p>So, I assume that there is something wrong with the other lines in the .htaccess that cause this error, does anybody have an idea what this could be?</p>
  
  <p>Any help is highly appreciated!</p>