title: How to redirect all attempts to access a folder to index, but server?
body: <p>I'm creating a new web site.</p>
  
  <p>The structure of this website is:</p>
  
  <pre><code>root
  ├─ .htaccess
  ├─ Index.php
  └─ Data
     └─Logo.png
  </code></pre>
  
  <p>My index page contains:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;img src="Data/Logo.png" alt="logo" height="42" width="42"&gt; 
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my .htaccess:</p>
  
  <pre><code>ErrorDocument 404 https://www.example.com/
  
  RewriteEngine On
  RewriteCond %{SERVER_PORT} !=443
  RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  
  Options +SymLinksIfOwnerMatch 
  RewriteEngine On 
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  
  RewriteEngine On 
  RedirectMatch 404 ^/Data/.*$ 
  </code></pre>
  
  <p>My problem:</p>
  
  <p>If in .htaccess file i set <code>RedirectMatch 404 ^/Data/.*$</code> , then no visitor is able to access <code>example.com/Data/Logo.png</code> , but <code>index.php</code> can't show the image.</p>
  
  <p>If in .htaccess file i set <code>RedirectMatch 404 ^/Data/?$</code> , then <code>Index.php</code> is able to show the image, but any visitor can access to <code>example.com/Data/Logo.png</code></p>
  
  <p>I want <code>/Data</code> to store images, php functions, styles and every other class.</p>
  
  <p>My question:</p>
  
  <p>How must i configure <code>htaccess</code> file to deny access to all visitors, but allow <code>Index.php</code> (and any other page in the website) to acces that folder?</p>