Forum Moderators: coopster

Message Too Old, No Replies

Automatic include

Automatic include

         

xalex

6:23 pm on Aug 3, 2005 (gmt 0)

10+ Year Member



I want to automatically include one php file in all my webpages. This is for tracking purpose and must be included before any header information is sent.

The problem is I have 1200 pages and it would be not efficient to edit and put the "include" command in every webpage. Is there a way to do an inculde from a server end before a php file is called?

jatar_k

6:37 pm on Aug 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



auto_prepend

i think that is what it is called, not sure

encyclo

6:41 pm on Aug 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you can use a .htaccess file and add:

php_value auto_prepend_file /path/to/include-file.php

As it is an .htaccess solution, your server needs to be running Apache (as opposed to IIS, etc.).

xalex

7:21 pm on Aug 3, 2005 (gmt 0)

10+ Year Member



If I use .htaccess in my root folder of the web, will it work for subfolders?

ergophobe

8:44 pm on Aug 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It should. The normal way that .htaccess works is to affect all files and directories below it unless overridden by something further down the tree (er.... up the tree actually I guess).