I have http:// and https:// on the same host like the following:
server { listen 80; listen 443 ssl; ... ... }
What I
Ideally, avoiding if statements while preserving the trailing path:
server { listen 80; server_name example.com; rewrite (.*) https://example.com$1 permanent; }
permanent takes care of the 301.