AllowOverride in Virtual Host using Directory Block

Created 16 years ago by Matt,
Last updated August 5th 2024, 3:50:07 pm

I know this may seem a little simple, but it took me a while to work this one out.

I was trying to get my installation of XAMPP to allow me to put php_value values into my .htacces file, for a site defined in a <VirtualHost> block. e.g. .htaccess file contents:

php_value include_path C:...~pathtodomain~... php_value auto_prepend_file config.php

RewriteEngine on RewriteBase / RewriteRule !.[a-z]{2,4}$ urlparser.php

The problem I was having was that my error logs kept saying

[Wed Jul 23 10:15:47 2008] [alert] [client 127.0.0.1] C:/...~pathtodomain~.../public_html/.htaccess: php_value not allowed here

This lead me to do some Google-ing, and I came across this site which went a fair way to help, I had not put in an AuthConfig block into my httpd.conf (or httpd-vhosts.conf / httpd-userdir.conf) file. But as it turns out, you cant just put that into a virtual host file, but you have to enclose it into a <Directory> block.

The final thing therefore looks like:

<VirtualHost mydomainame.co.uk.local:80>
    DocumentRoot "C:...~pathtodomain~...public_html"
    ServerName mydomainame.co.uk.local
    <Directory "C:...~pathtodomain~...public_html">
      AllowOverride All
    </Directory>
</VirtualHost>

Bearing in mind that the AllowOverride All should probably be used very carefully, and should probably have been AllowOverride AuthConfig. I found it to be a little flakey however, as Apache seemed to fail a few times when I try to start it with the above. Maybe I'm not giving it time to shut down correctly between restarts?

The .local domain is defined in my hosts file, to allow this .local domain to point to my local machine (see see Wikpedia)

Comments

  1. Oh my, thank you so much for this post! It has solved my problems after a whole weekend of annoyed frustration. I placed that into my httpd-vhost.conf file and everything is finally working as expected. Phew! Thanks, again! - Stephanie on Mon May 23 2011 05:57:42 GMT+0000 (Coordinated Universal Time)