要在 Nginx 中匹配目录结尾并重写添加 index.html 后缀,可以使用 location 块和 rewrite 指令来实现。\n\n例如,如果要将所有以 "/example/" 结尾的 URL 重写为 "/example/index.html",可以使用以下配置:\n\n\nserver {\n ...\n location /example/ {\n rewrite ^(.*)$ $1index.html;\n }\n ...\n}\n\n\n在上述配置中,location 块指定了匹配以 "/example/" 开头的 URL,并使用 rewrite 指令将匹配的 URL 重写为加上 "index.html" 后缀的 URL。$1 表示匹配的 URL 的正则捕获组。\n\n请根据您的具体需求修改上述配置。

Nginx URL 重写: 添加 index.html 后缀到目录结尾

原文地址: https://www.cveoy.top/t/topic/puIO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录