title: Allow file access from code, but block from browser?
body: <p>I have my <code>.htaccess</code> file, and I have a folder with config files in there, and they contain sensitive content, e.g. database details etc. What I would like to know is, how can I block access from a browser, but allow them to be accessed via my scripts? </p>
  
  <p>I know that this can be achieved inside the PHP files themselves, but I'd rather use the <code>.htaccess</code> approach where possible.</p>
  
  <p>Is this actually able to be done? I've attempted it before, but in the process of denying access to the file from the browser, it also denied access from the coding.</p>
  
  <p>I have looked into this before, and some of the answers I came across suggested changing the extension to something like <code>.inc</code>, and then denying access to that. However, a couple of issues I have with that is that a) It instantly alerts anyone that can see that filename, for whatever reason, that it is a config file. Also, b) If my denial code breaks, browsers will not parse it as a PHP file, but rather an <code>inc</code> file, meaning it will print the code in the browser. </p>
  
  <p>Basically, can this be done within a <code>.htaccess</code> file, or do I need to put something in the header of every config file?</p>