Greetings.<br><br>I want to redirect certain URL&#39;s to https. I&#39;ve come up with a few ways that I think will work but I&#39;m wondering which method is more efficient in terms of how much processing nginx would do.<br>
<br>1st method: multiple &#39;location&#39; sections.<br><br>location /sub1 {<br>&nbsp;&nbsp;&nbsp; rewrite ^(.*) https://$host$1 redirect;<br>}<br>location /sub2 {<br>&nbsp;&nbsp;&nbsp; rewrite ^(.*) https://$host/sub2 redirect;<br>}<br><br>2nd method: one location w/ multiple redirects.<br>
<br>location / {<br>&nbsp;&nbsp;&nbsp; rewrite ^(/sub1.*) https://$host$1 redirect;<br>&nbsp;&nbsp;&nbsp; rewrite ^(/sub2.*) https://$host$1 redirect;<br>}<br><br>3rd method: match using $scheme.<br><br>if ($scheme ~ http) {<br>&nbsp;&nbsp;&nbsp; rewrite ^(/sub1.*) https://$host$1 redirect;<br>
&nbsp;&nbsp;&nbsp; rewrite ^(/sub2.*) https://$host$1 redirect;<br>
}<br><br>My guess is that method 1 would be more efficient because rewrite processing would only happen if the location matched.<br><br>Thanks,<br>-Jake<br>