title: How to prevent direct access to files but allow files in webpages
body: <p>I'm trying to use mod.rewrite to deny direct access to files on my web server, e.g. <a href="http://domain.tld/reports/imareport.pdf" rel="nofollow noreferrer">http://domain.tld/reports/imareport.pdf</a> or <a href="http://domain.tld/img/img1.png" rel="nofollow noreferrer">http://domain.tld/img/img1.png</a>, and I've used the answer on this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/10236717/htaccess-how-to-prevent-a-file-from-direct-url-access">(htaccess) How to prevent a file from DIRECT URL ACCESS?</a></p>
  
  <p>That page suggests using mod.rewrite like this:</p>
  
  <pre><code>RewriteEngine on 
  RewriteRule \.(png|pdf|htm)$ - [F]
  </code></pre>
  
  <p>Using mod.rewrite in this manner works fine for denying access to PDFs, but other files that are ordinarily included in a page such as images and css are not only blocked from direct access, but also blocked when used on a webpage in a normal <code>&lt;img&gt;</code> tag or whatever.  This is contrary to the question and answer mentioned above.</p>
  
  <p>So... my question is... is there a way to block direct access to files but still allow them in webpages?</p>