頁面1:
index.html
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>index</title> 6 </head> 7 <body> 8 <!--#include virtual="common/header.html"--> 9 </body> 10 </html>
頁面2:
header.html
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>header</title> 6 </head> 7 <body> 8 hello world! 9 </body> 10 </html>
打開nginx的SSI服務:
修改D:\nginx\conf\nginx.conf,在service中增加下面配置。
ssi on; ssi_silent_errors on; ssi_types text/shtml;
注:如果要在html靜態頁面中使用include,則需要借助nginx服務且需要開啟ssi 服務才能生效!!