mike
April 22, 2008, 2:59am
1
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;
}
mike
April 22, 2008, 3:47am
2
I use two server blocks and everywhere I looked for examples they use
that. So i guess it is safe to use two server blocks as in your first
example it will check the regex every time you have a request, which
is slower than no regex at all
Kiril
mike
April 22, 2008, 4:09am
3
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 ;
...
}
mike
April 22, 2008, 7:16am
4
On Mon, Apr 21, 2008 at 05:50:25PM -0700, mike wrote:
set $name $1;
}
server {
listen 80;
server_name www.michaelshadle.com ;
rewrite ^/(.*) http://michaelshadle.com/$1 permanent;
}
Second, of course.