tags:

views:

66

answers:

1

Yet another nginx rewrite rule question

How can I do a rewrite from http://www.*.domain.com to http://*.domain.com ?

thanks in advance

Deb

A: 
if ($host ~* www\.(.*)) {
  set $host_without_www $1;
  rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
}

Answer from server fault: http://serverfault.com/questions/139579/nginx-subdomain-rewrite

deb