Add a training slash for nginx websites

In Nginx web servers, most of us might have came across a situation where our sub folder access wont work some times and if we add a trailing slash , it start to work
ie
http://domain.com/sub-folder  wont work
when http://domain.com/sub-folder/  works.

Fix add a redirect rule to auto insert the trailing slash – here is the code for that

rewrite ^/([^.]*[^/])$ $1/ permanent;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu