Lenny-Hu / note

blog
5 stars 1 forks source link

用nginx的ssi让html支持include html #67

Open Lenny-Hu opened 5 years ago

Lenny-Hu commented 5 years ago

一个常见的网站有很多公共页面,比如header和footer,在开发静态页面中,为了避免拷贝多份,可使用nginx的ssi来实现。

nginx 配置文件新增

location / {
            ssi on; # 开启ssi
            ssi_silent_errors on;
            # root   D:\\app;  如果是本地目录,启用这项
            # index  index.html index.htm;
            proxy_pass   http://127.0.0.1:3000; # 已有其他服务的时候,转发到其他服务
 }

浏览器输入 nginx 监听的地址,比如 http://localhost:9999 即可