I am supplying free wi-fi compatability service and want an advertisement to be included to all page demands.

Presently I've got a router sending all http demands for an apache server, which redirects all demands for an index.php page. The index.php page reads the request, brings this content in the appropriate site, and edits this content to incorporate the ad.

However , all images and css files etc. can't be utilized, because once the browser tries to obtain the image <img src="site.com/image.digital"> it is simply rerouted to the index.php.

I'm able to change configurations for that router (running dd-wrt) and also the webserver (apache2 and php 5.2).

It is possible to solution that enables content to become edited before coming back towards the client, and enables css and pictures to become utilized?

Apache is most likely not the best tool to do the job, you need to consider Squid, a http proxy with support for redirectors.

BTW: You'll have a large amount of fun with Squid