-1

there is a way to intercept an HTML DOM using an apache module and alter it with PHP?

The purpose is apply a set of PHP rules on all websites hosted on server (for example, replacing some strings).

SOLVED

I will update later with the solution

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user3817605
  • 151
  • 3
  • 11
  • What you need is a "proxy". If you search for a PHP proxy you'll find many scripts to build upon. – tacone Jun 03 '15 at 12:27
  • @tacone I never found a php based proxy that really worked without issues. I would not invest into that approach... – arkascha Jun 03 '15 at 17:56
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Jun 06 '15 at 21:16

2 Answers2

0

you could try using the htaccess (possibly set-able server wide in apache conf) value:

php_value auto_prepend_file

I've used that before for handling any errors php throws, so with a little hacking you could have it prepend a script that buffers content and modifies it, I'm not sure how foolproof you can make it though.

thelastshadow
  • 3,406
  • 3
  • 33
  • 36
0

This certainly is possible, different approaches exist.

Here an example of what I do to add a js tracking snippet to pages: http://blog.christian-reiner.info/2013/01/23/piwik/ The basic steps I use in there are: server side inclides (SSI) and substitution of closing body tags in all delivered html pages by preceding it with a small javascript. That javascript is generated by means of php. So a small php script is called automatically by the apache http server right before sending any html page to a client to add this small script.

Other good starting point certainly is apaches mod_ext_filter: http://httpd.apache.org/docs/current/mod/mod_ext_filter.html

arkascha
  • 41,620
  • 7
  • 58
  • 90