Site-wide include_file

Discussion in 'Apache' started by ForumJoiner, Apr 11, 2007.

  1. #1
    Is it possible, using .htaccess, to append a certain file to all php files from the entire site? I'm thinking about adding a statistics.php to all php files, without manually including the statistics.php in every php file.
     
    ForumJoiner, Apr 11, 2007 IP
  2. abdussamad

    abdussamad Active Member

    Messages:
    543
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You could do a wildcard internal redirect to another php file which then includes both the stats file and the file requested by the user. MAybe something like this in .htaccess

    
    rewriteengine on
    rewritebase /
    rewriterule (*.)$ global.php?file=$1 [nc,l]
    
    Code (markup):
    In global.php

    
    <?
    include ("stats.php");
    
    include($_GET['file']);
    ?>
    
    PHP:
     
    abdussamad, Apr 13, 2007 IP