nystudio107 / nginx-craft

An Nginx virtual host configuration for Craft CMS that implements a number of best-practices.
MIT License
310 stars 36 forks source link

Adding trailing slash causes an unnecessary 307 internal redirect #22

Open peimansh opened 4 years ago

peimansh commented 4 years ago

I have found an issue where Nginx tries to add trailing slash to the URIs, then there happens double redirect. The default redirect for adding trailing slash does the redirect in HTTP protocol and then does another redirect to HTTPS which causes an extra unnecessary "internal redirect 307" status in the process.

For example: https://somedomain.com/some-article --> http://somedomain.com/some-article/ -301 moved permanently http://somedomain.com/some-article/ --> https://somedomain.com/some-article/ -307 internal redirect https://somedomain.com/some-article/ --> 200 status OK

I'm not expert in Nginx configurations so I'm wondering if this could be solved by some code tweak or this is a code bug and should be patched.