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()
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With