How to add HTML code to every HTML document?

I need to add a script before the </body> , so instead of changing all the pages, I was wondering if I can configure the server to add some HTML before this tag for each served HTML document?

+4
source share
3 answers

If you have PHP installed on your server, you can configure the auto_append and / or auto_prepend in the php.ini or .htaccess file. You can also configure .html extensions for analysis in Apache PHP files, so every HTTP request for a .html document is sent back with a header, and the footer is automatically included. If PHP is configured, try adding these lines to your .htaccess:

 AddType application/x-httpd-php .html php_value auto_prepend_file /var/www/public/foo.html 
+4
source

Apache can handle this with mod_layout

Here's the related article: Apache Advanced Headers and Footers

+2
source

The most natural answer to your problem would be to use a server-side processing language such as PHP, CGI, etc. These platforms provide much more than just the server side. Saying that if you include something on an HTML page, this is really what you need, you can look for Server Side Includes .

+1
source

Source: https://habr.com/ru/post/1285869/


All Articles