NGINX 删除 uri 中的所有扩展类型

NGINX 删除 uri 中的所有扩展类型

如何通过 nginx 配置删除 uri 中的所有扩展类型。我四处寻找解决方案,但只找到了针对特定文件类型的解决方案。例如,某些配置会重写所有 html 文件。将 abc.com/hello/world.html 重写为 abc.com/hello/world。其他人使用 php 执行此操作。我正在尝试创建一个配置来获取 uri 并删除扩展名,将索引重定向到 /,并删除 uri 末尾的任何额外反斜杠。

这里有些例子:

/hello/world.php -> /hello/world (输入 /hello/world 将会按顺序呈现 /hello/world.php、html、asp、txt,但不会在 URL 栏中显示扩展名)

/你好/index.php-> /你好

/你好/-> /你好

/你好/world.html->/你好/world

ETC。

相关内容