Forum Moderators: phranque

Message Too Old, No Replies

php value auto append file in .htaccess

getting the server setup right

         

dhiggerdhigger

12:51 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Am I right in thinking that the .htaccess command "php_value auto_append_file" e.g.

<FilesMatch "\.(html?)$">
php_value auto_append_file /server/path/to/my/www_root/subdir/file.ext"
</FilesMatch>

will not work unless

<Directory "/server/path/to/my/www_root">
AllowOverride All
</Directory>

is placed in httpd.conf?

My hosting provider offered to place the <Directory> block in my <VirtualHost> block, but I understand that a <Directory> block must not be within a <VirtualHost> block. I got my host to put it before the <VirtualHost> block, but then Apache (v1.3.37, with php5 as a CGI) wouldn't restart (error at line... etc, I don't have the error details or the specific line number).

Are we doing anything wrong?

matc

1:31 am on Sep 14, 2006 (gmt 0)

10+ Year Member



Hi,

AllowOverride All will trip up out of context, e.g,
[httpd.apache.org...]

Here are the best fit uses for this directive:
[httpd.apache.org...]

cheers, matc

dhiggerdhigger

8:25 am on Sep 14, 2006 (gmt 0)

10+ Year Member



So, I assume AllowOverride All is required, for the php_value command to be effective?

And why does Apache trip up (as described above) when it's correctly placed in a <Directory> block? Is there anything we're missing?

matc

1:44 pm on Sep 14, 2006 (gmt 0)

10+ Year Member



Hi,

Long reply.....

Aha, so it was applied within a directory block... I got the impression it was stand alone hence the context statement. Also as far as I am aware the httpd.conf parses from the bottom up so if it came across something near the bottom of the file that didn't take then everything else above would fail... ahem .. as ever I’m happy to be corrected

Also just to be clear the Directory directive has the following consideration

“The directory sections occur in the httpd.conf file. <Directory> directives cannot nest, and cannot appear in a <Limit> or <LimitExcept> section.”

Anyway, running apache2, as I haven't used Apache 1.3 in years, and applying a change like this could be tried out like this...

Untested httpd.conf

<VirualHost *:81>
DocumentRoot "/server/path/to/my/www_root"
ErrorLog "/server/path/to/my/logs/error.log"
CustomLog "/server/path/to/my/logs/access.log"
<Directory "/server/path/to/my/www_root">
AllowOveride All
Allow from all # default anyway
Order allow,deny
</Directory>
</VirtualHost>

Something I found out about 'php_value' which might be handy to know is that in apache2 it is best stated as 'php_admin_value' due to a badly documented change between the two versions of Apache and supported PHP releases... as far as I’ve read anyway... Also most implementations of 'php_value' I've seen have been stated in the Directory or DirectoryMatch directives but I can't see why a nested FileMatch within these should do any harm and might make it a bit more tidy..

A suggestion would be to tie the Directory or DirectoryMatch directive to a specifically stated local location path and bundle all the needed staments in that..

Untested httpd.conf

<VirtualHost *:81>
#*... directives ...*
<Directory "/server/path/to/my/www_root/">
AllowOveride All
#*... directives ...*
</Directory>
</Virtualhost>

Untested .htaccess

<Directory “/subdir/”>
<FilesMatch "\.(html?)$">
php_value auto_append_file /server/path/to/my/www_root/subdir/file.ext
</FilesMatch>
</Directory>

This stuff is mostly my stream of consciousness but I hope it helps, theres a few things to try and research further on anyway.

cheers, matc

dhiggerdhigger

2:40 pm on Sep 20, 2006 (gmt 0)

10+ Year Member



It seems that you're advising putting a <Directory> block within the <VirtualHost> block in httpd.conf (contrary to what I originally thought - see first post). Well I got my hosting provider to put

<Directory "/server/path/to/my/www_root">
AllowOverride All
</Directory>

in my VirtualHost section of the httpd.conf. Unfortunately, I'm still getting notices in my error logs of the command "php_value" not being recognised (when I try to use it in .htaccess):

<FilesMatch "\.(html?)$">
php_value auto_append_file "/home/revise/public_html/count/bbclone.php"
</FilesMatch>

So it hasn't worked. Any ideas why?