I have a particular server setup where blog.html
is next to a blog/
dir.
The problem is that when a URL is directed to blog.html, e.g., https://website.com/blog
, a backslash is automatically appended (presumably because it sees that a dir is present) which then results in a forbidden error.
blog.html
serves as an index, and blog/
contains sub pages:
https://website.com/blog
should be valid and show all articles
https://website.com/blog/
should result in a redirect to https://website.com/blog
https://website.com/blog/article-1
should resolve to the corresponding subpage.
I've tried to redirect if there's a trailing backslash, e.g.,: rewrite ^/(.+)/$ $1 permanent;
but none of the variations I've tried have helped.
Posts I've attempted to implement to no avail:
How to stop nginx 301 auto redirect when trailing slash is not in URI? https://stackoverflow.com/questions/35973947/how-to-redirect-no-www-to-www-under-jwilder-nginx-proxy https://stackoverflow.com/questions/55129752/rewrite-url-in-jwilder-nginx-proxy-docker-container
How can I configure nginx to not auto resolve to the directory and accept the non-backslash URL without issue?