博客
关于我
nodejs支持ssi实现include shtml页面
阅读量:801 次
发布时间:2023-02-16

本文共 392 字,大约阅读时间需要 1 分钟。

Express 对于 include 的代码默认不处理,直接输出,无法执行包含的内容。但可以通过 Nginx 实现。

配置 Nginx 开启 SSI 模式

在 Nginx 配置中,开启 SSI 模式并设置相关选项:

server {    ...    ssi on;    ssi_silent_errors on;    ssi_types text/shtml;    ...}

添加包含页面

在 HTML 文件中添加包含内容:

或者:

注意virtual 模式下,路径是相对服务目录的。

虚拟目录示例

假设虚拟目录结构如下:

--- /var/www/html    --- public        --- index.html        --- bottom.shtml

实现效果

通过上述配置,可以实现 include 内容的正确加载,效果如图所示。

转载地址:http://ixjfk.baihongyu.com/

你可能感兴趣的文章
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
npm scripts 使用指南
查看>>
npm should be run outside of the node repl, in your normal shell
查看>>
npm start运行了什么
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>