问题描述
我不知道Apache还是 .htaccess
是正确的方法,但是我想知道如何在<$ c内的所有页面中插入HTML代码$ c> public_html 目录,有点像2000年代初的免费主机,他们在所有页面中插入横幅。
注意:我不是谈论手动编辑每个页面并添加 SSI
或PHP的 include()
您可以使用以下方法使用 .htaccess
将HTML代码插入特定目录内的所有页面:
<目录 / public_html />
#附加到顶部
php_value auto_prepend_file /dir/path/banner.php
#附加到底部
php_value auto_append_file / dir / path / footer。 php
< / Directory>
下面的文章讨论了.htaccess如何允许您在每个页面请求之前添加html: / p>
以下文章讨论了如何使用.htaccess目录块:
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
这篇关于通过Apache在所有页面中插入HTML代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!