nginx 如何配置指向带有hash值的index.html文件?-灵析社区

满脑子智慧溢出

现场景如下: react 项目中打包生成的index.html 文件,包含有一个哈希值: index.as23fs.html 类似这种。 在nginx 中配置指向的时候,不知道如何指向index.**.html, location / { root html/demo; index index.html index.html; // 想要使用方法指向index.as23fs.html try_files $uri $uri/ /index.html; } 请教各位老铁们了

阅读量:210

点赞量:11

问AI
用正则表达式: server { listen 80; location / { root html/demo; index index.html; try_files $uri $uri/ @hashed; } location @hashed { if (-f $document_root$uri/index.*.html) { rewrite ^/(.*)/$ /$1/index.*.html break; } try_files $uri =404; } }