Search code examples
php.htaccessapache2

How do I use the AllowOverride directive to permit .htaccess files to override php_value (Apache2)


I want to set the values of three different php_value parameters, on a per <VirtualHost> basis, using each hosts .htaccess file. Presumably in order to do this, I would need to place an AllowOverride directive within each <VirtualHost> configuration to permit the overriding of these values; I do not want to simply use AllowOverride All because that seems much too permissive and a bit overkill.

The problem seems to be that php_value is not an Apache2 directive, and nor are the names of specific values such as memory_limit, max_upload_filesize and max_post_size; however AllowOverride seems to only accept a subset of Apache2 directives as it's argument, as well as things like All, Option, etc.

Can anyone point me in the right direction? I'm aware that I could simply use php.ini or include the php_value definitions within the <VirtualHost> configuration itself, but I'd really like to find out how it is done via the .htaccess file first.


Solution

  • Per the "How to change configuration settings" documentation, AllowOverride Options is required to use the php_value directives. This is of course implicit in AllowOverride All. You do not use php_value as an argument to AllowOverride, php_value is a directive provided by mod_php, if you are not able to use it, you may not be running PHP as an Apache module. If so, so you will need to use other methods of customizing the configuration on a per-site basis.

    The configuration example in the the documentation is a good starting point. Step one is to verify that you are running mod_php. After that, provided you have set AllowOverrides appropriately for the virtual host, you should be able to simply add the php_value declarations to your .htaccess files. For instance, I just tested adding this line to a .htaccess file:

    php_value arg_separator.input &|,
    

    Result: enter image description here