让Nginx 的URL目录自动加斜线”/”

默认配置当你访问http://abc.example.com/dir 时不会加”/”

常见做法

if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}

更佳的替代方法

optimize_server_names off;#优化服务器名称:关
server_name_in_redirect off;#服务器名称重定向:关

原文地址:https://www.cnblogs.com/top5/p/1588460.html