The Apache::Sandwich module allows you to add per-directory custom "header" and "footer" content to a given URI. Works only with GET requests. Output of combined parts is forced to text/html. The handler for the sandwiched document is specified by the SandwichHandler configuration variable. If it is not set, default-handler is used.
The basic concept is that the concatenation of the header and footer parts with the sandwiched file in between constitutes a complete valid HTML document.
Available from CPAN. See the module manpage for more information.