0

I'm trying to inject a tracking code to all the website files.. after googling for a while a found a tutorial to do it from .htaccess .. this is how it works

Options +Includes
AddHandler server-parsed .html
AddHandler application/x-httpd-php .html
php_value auto_prepend_file /var/www/to_include.php
php_value auto_append_file /var/www/to_include2.php

to_include.php has a php ob_start() to buffer the page contents and add my code to it, and to_include2.php has the ob_end_flush() that goes to the end of the page...

That's good till now, but it doesn't apply it to every single file ..

I'm not an htaccess expert but as you see the second and third line where it says

AddHandler server-parsed .html
AddHandler application/x-httpd-php .html

it says only apply it to .php and .html files, How can i use AddHandler to handle all kind of files, including apache directories.. it has no extension but i also want some line that does it to every visited page on the website,

My target is to track all kind of moves on the website and inject google analytics to each file

Osa
  • 1,922
  • 7
  • 30
  • 51

1 Answers1

0

What do you need server-parsed files for in this?

Did you try AddHandler application/x-httpd-php .* ?

Think of a different solution anyways if it won't work. mod_rewrite might also help, redirect * to your script, ...

.htaccess files usually only apply for its directory and subdirectories, make sure it's in the root dir.

Daniel W.
  • 31,164
  • 13
  • 93
  • 151