Which is better?

Dave Cheney dave at cheney.net
Tue Apr 22 05:58:35 MSD 2008


We have an SEO directive to only publish on one url, but also support  
a HUGE set of typo domains, we use this stanza

   server {
     listen 80 default;

     rewrite ^(.+)$ http://www.redbubble.com$1 permanent;
   }

   server {
     listen 80;
     server_name www.redbubble.com;

     ...

  }


On 22/04/2008, at 10:50 AM, mike wrote:
> Is one better than the other?
>
> combining www. and non-www, and using a conditional:
>
> server {
>    listen 80;
>    server_name michaelshadle.com www.michaelshadle.com;
>    ... index, root, all that stuff...
>
>    if ($http_host ~ "^www.(.*)") {
>        set $name $1;
>        rewrite ^/(.*) http://$name/$1 permanent;
>    }
> }
>
> or making two physical server blocks?
>
> server {
>    listen 80;
>    server_name michaelshadle.com;
>    ... index, root, all that stuff...
>
> }
>
> server {
>    listen 80;
>    server_name www.michaelshadle.com;
>    rewrite ^/(.*) http://michaelshadle.com/$1 permanent;
> }
>






More information about the nginx mailing list