Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert HTML code in all pages via Apache?

I don't know if Apache or .htaccess is the right way, but I like to know how to insert an HTML code to all pages inside a public_html directory, kinda like free hosts in the early 2000s where they insert their banner in all pages.

Note: I am not talking about manually editing each page and adding SSI or PHP's include()

like image 829
IMB Avatar asked Oct 31 '22 22:10

IMB


1 Answers

You can use the following method to insert HTML code to all pages within a specific directory using .htaccess:

<Directory "/public_html/">
    # Prepend to top
    php_value auto_prepend_file "/dir/path/banner.php"

    # Append to bottom
    php_value auto_append_file "/dir/path/footer.php"
</Directory>

The following article discusses how .htaccess can allow you to prepend/append html to every page request:

http://davidwalsh.name/prepend-append-files-htaccess

The following article discusses how to use the .htaccess directory block:

htaccess <Directory> deny from all

like image 198
samland Avatar answered Nov 09 '22 11:11

samland