user702300
user702300

Reputation: 1241

Nginx: Add trailing slash to specific URL only

I am trying to redirect the following URL by adding a trailing slash

http://mywebsite.com/download (main CMS will take over to show page not found)

to

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

I tried to search on the Internet and although there are plenty of info for adding trailing slashes for all URLs in the site, I ONLY WANT to add to the "download" segment, but can't find any info on this.

Thank you.

Upvotes: 0

Views: 3462

Answers (1)

skip87
skip87

Reputation: 529

Add the following line to your config file. return 301 http://$host$uri/ ; in location /download part. like below

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

Upvotes: 4

Related Questions