User Tools

Site Tools


Sidebar


italmedia.net

apache:allowoverride-in-vhost

AllowOverride in Virtual Host using Directory Block

Posted: Wed 23rd Jul 2008@09:26 www.stabeler.com

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 .htaccess 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 Wikipedia)

apache/allowoverride-in-vhost.txt · Last modified: 2013-01-30 10:52 (external edit)