I want to create a rule in nginx that does two things:
- Removes the "www." from the request URI
- Redirects to "https" if the request URI is "http"
There are plenty of examples of how to do each of those things individually, but I can't figure out a solution that does both correctly (i.e. doesn't create a redirect loop and handles all cases properly).
It needs to handle all of these cases:
1. http://www.example.com/path 2. https://www.example.com/path 3. http://example.com/path 4. https://example.com/path
These should all end up at https://example.com/path (#4) without looping. Any ideas?