title: .htaccess files, PHP, includes directories, and windows XAMPP configuration nightmare
body: <p>XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite disappointing that enabling <code>.htaccess</code> files is such a nightmare.</p>
  <p>My problem:
  I've got a PHP application that requires apache/php to search for an <code>/includes/</code> directory contained within the application. To do this, <code>.htaccess</code> files must be allowed in Apache and the <code>.htaccess</code> file must specify exactly where the includes directory is.</p>
  <p>Problem is, I can't get my Apache config to view these <code>.htaccess</code> files. I had major hassles installing this app at uni and getting the admins there to help with the setup. This shouldn't be so hard but for some reason I just can't get Apache to play nice.</p>
  <p>This is my setup:</p>
  <p><code>c:\xampp</code>
  <code>c:\xampp\htdocs</code>
  <code>c:\xampp\apache\conf\httpd.conf</code> - where I've made the changes listed below
  <code>c:\xampp\apache\bin\php.ini</code> - where changes to this file affect the PHP installation
  It is interesting to note that <code>c:\xampp\php\php.ini</code> changes mean nothing - this is NOT the ini that affects the PHP installation.</p>
  <p>The following lines are additions I've made to the <code>httpd.conf</code> file</p>
  <pre><code>#AccessFileName .htaccess
  AccessFileName htaccess.txt
  #
  # The following lines prevent .htaccess and .htpasswd
  # files from being viewed by Web clients.
  #
  #&lt;Files ~ &quot;^\.ht&quot;&gt;
  &lt;Files ~ &quot;^htaccess\.&quot;&gt;
      Order allow,deny
      Deny from all
  &lt;/Files&gt;
  
  &lt;Directory &quot;c:/xampp/htdocs&quot;&gt;
  #
  # AllowOverride controls what directives may be placed in
  # .htaccess files.
  # It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:
  #   Options FileInfo AuthConfig Limit
  #
      AllowOverride All
  #
  # Controls who can get stuff from this server.
  #
      Order allow,deny
      Allow from all
  &lt;/Directory&gt;
  </code></pre>
  <p>The following is the entire <code>.htaccess</code> file contained in:
  <code>c:\xampp\htdocs\application\htaccess.txt</code></p>
  <pre><code>&lt;Files ~ &quot;\.inc$&quot;&gt;
    Order deny,allow
    Deny from all
  &lt;/Files&gt;
  
  php_value default_charset &quot;UTF-8&quot;
  php_value include_path &quot;.;c:\xampp\htdocs\application\includes&quot;
  php_value register_globals 0
  php_value magic_quotes_gpc 0
  php_value magic_quotes_runtime 0
  php_value magic_quotes_sybase 0
  php_value session.use_cookies 1
  php_value session.use_only_cookies 0
  php_value session.use_trans_sid 1
  php_value session.gc_maxlifetime 3600
  php_value arg_separator.output &quot;&amp;amp;&quot;
  php_value url_rewriter.tags &quot;a=href,area=href,frame=src,input=src,fieldset=&quot;
  </code></pre>
  <p>The includes directory exists at the location specified.</p>
  <p>When I try to access the application I receive the following error:</p>
  <pre><code>Warning: require(include.general.inc) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\application\menu\logon.php on line 21
  </code></pre>
  <p>Fatal error: require() [function.require]: Failed opening required <code>include.general.inc</code> (include_path='.;C:\xampp\php\pear\random') in <code>C:\xampp\htdocs\application\menu\logon.php</code> on line 21</p>
  <p>The include path <code>c..\random\</code> is specified in the <code>php.ini</code> file listed above. The XAMPP install fails to allow another include path as specified in the <code>htaccess.txt</code> file.</p>
  <p>I'm guessing there's probably an error with the <code>httpd.conf</code> OR the <code>htaccess.txt</code> file.. but it doesn't seem to be reading the <code>.htaccess</code> file. I've tried to be as thorough as possible so forgive the verbosity of the post.</p>
  <p>Now I know a workaround could be to simply add the include_path to the PHP file, but I'm not going to have access to the <code>php.ini</code> file on the location I plan to deploy my app. I will, however, be able to request the server admin allows <code>.htaccess</code> files.</p>
  <p>renamed <code>htacces.txt</code> to <code>.htaccess</code> and ammended the appropriate directives in the <code>httpd.conf</code> file and all seems to work. The application suggested the naming of <code>htaccess.txt</code> and the ammended directives in the httpd. These are obviously wrong (at least for a XAMPP stack).</p>
  <p>By the way, using ini_set() is a much friendlier way if the app needs to be deployed to multiple locations so thanks especially for that pointer.</p>