I have some 100 or so URLs that need to be permanently redirected from static HTML to dynamic pages served by Wordpress. All examples for Nginx 301 redirection I found suggest that each redirect should be defined as its own server block.
However, I have found out that multiple redirects within one server block work as well such as in this simplified configuration:
server { listen 80; server_name www.example.com; root /var/www/; location = /subdir/red1.html { return 301 /subdir/?p=1; } location = /subdir/red2.html { return 301 /subdir/?p=2; } location = /subdir/red3.html { return 301 /subdir/?p=3; } }
Curl -I confirms the 301 code. The redirects take place. I prefer this configuration to the one with one server block per redirect because human readability is better. But does this configuration lack something that I'd otherwise have if each redirect was in its own server block?