views:

148

answers:

3

I need to add a script before the </body> tag, so instead of modifying all the pages, I was wondering if I could configure the server to add some HTML before that tag for every HTML document being served?

+1  A: 

The most natural answer to your problem would be to use a server-side processing language such as PHP, CGI, etc. Those platforms give a lot more than just server-side includes. Speaking of which, if including something in an HTML page is just really what you need, you might be looking for Server Side Includes.

kizzx2
Yeah but my site already has all sorts of mixed up files. PHP, templates, plain HTML, etc.
Jenko
+4  A: 

If you have PHP installed on your server, you can set up the auto_append and/or auto_prepend directives in the php.ini file or .htaccess. You can also set up .html extensions to be parsed as PHP files by Apache, so every HTTP request for an .html document is sent back with a header and a footer automagically included. If PHP is set up, try adding these lines into your .htaccess:

AddType application/x-httpd-php .html 
php_value auto_prepend_file /var/www/public/foo.html
karim79
+2  A: 

Apache can handle that using mod_layout

Here's a relevant article: Advanced Apache Headers/Footers

Josh Stodola