Skip to content
Advertisement

.htaccess files, PHP, includes directories, and windows XAMPP configuration nightmare

XAMPP makes configuring a local LAMP stack for windows a breeze. So it’s quite disappointing that enabling .htaccess files is such a nightmare.

My problem: I’ve got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, .htaccess files must be allowed in Apache and the .htaccess file must specify exactly where the includes directory is.

Problem is, I can’t get my Apache config to view these .htaccess 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.

This is my setup:

c:xampp c:xampphtdocs c:xamppapacheconfhttpd.conf – where I’ve made the changes listed below c:xamppapachebinphp.ini – where changes to this file affect the PHP installation It is interesting to note that c:xamppphpphp.ini changes mean nothing – this is NOT the ini that affects the PHP installation.

The following lines are additions I’ve made to the httpd.conf file

JavaScript

The following is the entire .htaccess file contained in: c:xampphtdocsapplicationhtaccess.txt

JavaScript

The includes directory exists at the location specified.

When I try to access the application I receive the following error:

JavaScript

Fatal error: require() [function.require]: Failed opening required include.general.inc (include_path=’.;C:xamppphppearrandom’) in C:xampphtdocsapplicationmenulogon.php on line 21

The include path c..random is specified in the php.ini file listed above. The XAMPP install fails to allow another include path as specified in the htaccess.txt file.

I’m guessing there’s probably an error with the httpd.conf OR the htaccess.txt file.. but it doesn’t seem to be reading the .htaccess file. I’ve tried to be as thorough as possible so forgive the verbosity of the post.

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 php.ini file on the location I plan to deploy my app. I will, however, be able to request the server admin allows .htaccess files.

renamed htacces.txt to .htaccess and ammended the appropriate directives in the httpd.conf file and all seems to work. The application suggested the naming of htaccess.txt and the ammended directives in the httpd. These are obviously wrong (at least for a XAMPP stack).

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.

Advertisement

Answer

  1. Why do you need to rename .htaccess to htaccess.txt
  2. Try setting the include_path using set_include_path() and see if that helps (as an intermediate fix)
  3. Verify which php.ini to use through a phpinfo()
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement