Rewrite regexp for subdomains
António P. P. Almeida
appa at perusio.net
Sun Oct 31 22:06:10 MSK 2010
On 31 Out 2010 03h48 WET, nginx-forum at nginx.us wrote:
> It doesn't work. With server_name www.example.org and server_name
> *.example.org my site doesn't redirect blabla.example.org to
> www.example.org
server {
listen [::]:80; # ipv6
server_name www.example.com;
(...)
}
server {
## This is to avoid the spurious if for sub-domain name
## rewriting. See http://wiki.nginx.org/Pitfalls#Server_Name.
listen [::]:80; # ipv6
server_name *.example.com;
rewrite ^ $scheme://www.example.com$request_uri permanent;
} # server domain rewrite.
I haven't tried it myself. Try it.
--- appa
More information about the nginx
mailing list