title: .htaccess all directories give 403 Forbidden
body: <p>I'm using .htaccess on my multilingual website to make some URL modifications for nice SEO.</p>
  
  <p>By default all the folders are restricted with 403 Forbidden, but I want to make exceptions on two paths. <code>/de</code> and <code>/en</code>. Yes, these paths are for multilingual and when I have pages like: </p>
  
  <pre><code>www.mywebsite.com/en/page
  </code></pre>
  
  <p>It's working properly, but when I try to return to the main page with link like this:</p>
  
  <pre><code>www.mywebsite.com/en
  </code></pre>
  
  <p>it shows 403 forbidden.</p>
  
  <p>Here's my full code:</p>
  
  <pre><code>RewriteEngine on
  
  #remove .php
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^([^\.]+)$ $1.php [NC,L]
  
  #redirect lang
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+?)/(.*)$ $2.php?lang=$1 [L]
  
  
  RewriteCond %{REQUEST_URI} !/en
  </code></pre>
  
  <p>On the last line as you can see I've tried to allow access to <code>/en</code>, but it doesn't work.</p>
  
  <p>How can I allow the access of these paths: <code>/en</code> and <code>/de</code> ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>After lot of searching, I've found that the main website on the same server that's made on Drupal, it has own .htaccess file and that's why it shows 403 forbidden on the new website (custom cms) that is located on a separate folder inside. But when I delete the .htaccess from the main website as a test, now on the new website when I enter <code>www.mywebsite.com/en/</code> it shows 404 not found.</p>
  
  <p>That doesn't happen if I enter 
  <code>www.mywebsite.com/en</code></p>
  
  <p>It simply redirects to the index page.</p>
  
  <p>After double check I can see the language switcher on my website automatically change the languages, so if page was <code>/team</code>, it acts like <code>/en/team</code> and on the front page it acts like this <code>/en/</code>, not <code>/en</code>.</p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>I've followed the w3dk answer, but it still shows the same error.
  This is the full code that I'm trying out:</p>
  
  <pre><code>RewriteEngine on
  
  #remove .php
  #RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^([^\.]+)$ $1.php [NC,L]
  
  RewriteRule ^([^\.]+)/?$ $1/index
  
  
  #redirect lang
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+?)/(.*)$ $2.php?lang=$1 [L]
  </code></pre>
  
  <p>This line <code>RewriteRule ^([^\.]+)/?$ $1/index</code> breaks the language switcher functionality. For an example <code>/de/team</code> doesn't change to the German content. Right now I've commented that line, 'cos its not working properly. </p>
  
  <p>I'm posting the code from my language switcher too:</p>
  
  <pre><code>&lt;?php
  $currentURL = basename($_SERVER['REQUEST_URI']);
  ?&gt;
          &lt;ul class="language-switcher"&gt;
              &lt;li&gt;&lt;a href="/de/&lt;?php echo $currentURL; ?&gt;"&gt;DE&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="/en/&lt;?php echo $currentURL; ?&gt;"&gt;EN&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;   
  </code></pre>
  
  <p>If I enter this page </p>
  
  <pre><code>www.mywebsite.com/en/team
  </code></pre>
  
  <p>and after that click on the language switcher on German version, it successfully shows the German content and the URL is like this:</p>
  
  <p>www.mywebsite.com/de/team</p>
  
  <p>BUT if I go to the front page that has this URL:</p>
  
  <pre><code>www.mywebsite.com
  </code></pre>
  
  <p>and click on the language switcher on German version the URL becomes like this and it shows 403 or 404 page:</p>
  
  <p><code>www.mywebsite.com/de/</code></p>