通过Apache在所有页面中插入HTML代码? [英] Insert HTML code in all pages via Apache?

查看:184
本文介绍了通过Apache在所有页面中插入HTML代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道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>

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



以下文章讨论了如何使用.htaccess目录块:



htaccess< Directory>全部拒绝


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代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆