html中使用include引入另一個html文件


 

頁面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 服務才能生效!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM