Nginx:仅将尾部斜杠添加到特定 URL

Nginx: Add trailing slash to specific URL only

我正在尝试通过添加尾部斜杠

来重定向以下 URL
http://mywebsite.com/download (main CMS will take over to show page not found)

http://mywebsite.com/download/ (another standalone script will take over in this folder)

我尝试在 Internet 上搜索,虽然有很多信息可以为站点中的所有 URL 添加尾部斜线,但我只想添加到 "download" 部分,但是找不到关于此的任何信息。

谢谢。

将以下行添加到您的配置文件中。 return 301 http://$host$uri/ ; 在位置/下载部分。 如下图

location /download {
  return 301 http://$host$uri/ ;
}