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