title: .htaccess prevent folder access that are subdomains
body: <p>in my webhost every time I create a new subdomain it creates a public-access folder in my <em>html_public</em> folder, and I want to block the access to those folders with a fake 404 error (using the default one if it's possible, I'm using this to set the default 404 error: <code>ErrorDocument 404 /404.php</code>) but allowing to access if it is the subdomain.</p>
  
  <p>For example:</p>
  
  <pre><code>http://www.mydomain.com/blog/ -&gt; Should show a 404 Not found error
  http://blog.mydomain.com -&gt; Should allow the user to access
  </code></pre>
  
  <p>Both of them are the <strong>same</strong> folder <em>html_public/blog</em></p>
  
  <p>I tried to add a <strong>.htaccess</strong> file in <em>blog</em> folder with this code:</p>
  
  <pre><code>order deny,allow
  deny from all
  </code></pre>
  
  <p>But it does not allow the access (logic), it does not matters if it is folder or subdomain.</p>
  
  <p>And this one:</p>
  
  <pre><code>RewriteRule ^blog/* /404.php
  </code></pre>
  
  <p>But like other, it redirects all to a 404 error, instead of only the direct access to the folder and allowing the access to the subdomain.</p>
  
  <p><em>Note: I saw other questions that redirects from folder to subdomain, I need to show a 404 error.</em></p>
  
  <p>Can someone help me?
  Thanks in advanced.</p>