更新时间:2023-11-27 22:04:34
如果您使用的是Apache,您可以使用服务器端包含。这些基本上提供了HTML文档中的include语句。
安装并启用 mod_include
。配置
选项+包含
AddType文本/ html .shtml
AddOutputFilter INCLUDES .shtml
使用 .shtml
作为您的主页文件扩展名。然后在你的页面中,你可以做一些事情,比如:
<! - #include virtual =/ header.html - - >
Nginx也支持服务器端包含与它的SSI模块:
location / {
ssi on;
}
HTML:
<! - #include file =header.html - >
Simple problem I have so far always solved via PHP:
You have a site with header, menu, footer and content field.
Header, menu and footer are usually the same for each page.
So that for example you don't have ten pages (like home.html, products.html, about.html, ..) all having a copy of the static header and menu in their html files. Now if you want to change the header you have to change ten files.
I hope I made my question clear enough, if not please leave a comment :)
If you're using Apache, you can use server-side includes. These basically provide include statements within HTML documents.
Install and enable mod_include
. Configure
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Use .shtml
as your main page file extension. Then in your pages, you can do things like
<!--#include virtual="/header.html" -->
Nginx also supports server-side includes with it's SSI module:
location / {
ssi on;
}
HTML:
<!--# include file="header.html" -->