Which is better?

mike mike503 at gmail.com
Tue Apr 22 04:50:25 MSD 2008


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