Forum Moderators: coopster

Message Too Old, No Replies

A site-wide php includes problem

         

dhiggerdhigger

3:37 pm on Oct 4, 2006 (gmt 0)

10+ Year Member



I used to add some php code to every .htm page in my site using the .htaccess command

<FilesMatch "\.(html?)$">
php_value auto_append_file "/server/path/www_root/file.php"
</FilesMatch>

(and another command to make the Apache server parse .htm files for php)

But now I am on a host where the php_value command is not recognised.

Is there another way of getting my php code in file.php added to every page? I want to avoid adding an include command to every file. I realise this may be a question for the Apache forum, but I suspect that asking php users directly here may be just as productive!

eelixduppy

3:49 pm on Oct 4, 2006 (gmt 0)



If you cannot do it within your .htaccess then another option is your php.ini file, although I don't think that you have access to this either. You may be best off contacting your host for more information on the subject.

Good luck!

dhiggerdhigger

11:01 am on Oct 5, 2006 (gmt 0)

10+ Year Member



I've learned some more on this, perhaps someone can confirm of deny the following:

  • PHP loaded as a CGI and not a module means that 'php_value' won't work, in .htaccess.
  • ini_set() can be used to change settings in the php.ini file at script execution, and this may solve the problem (I can't find how, though).

    Dave

  • eelixduppy

    11:05 am on Oct 5, 2006 (gmt 0)



    >>>ini_set() can be used to change settings in the php.ini file at script execution

    This is true, however, not for auto_prepend_file because it is PHP_INI_PERDIR, unless you are using PHP 4.2.3 in which case this is possible. Although I wouldn't see why, because you are better off just including the file in each page then.