server name rewrite

wishmaster artemrts at ukr.net
Wed Jun 19 18:22:11 UTC 2013


Hi, guys!

E.g. I have server new_server_name.com and want to rewrite requests to www.new_server_name.com and old_server_name.com to present server.

>From http://wiki.nginx.org/Pitfalls I use two server's {} directives for this instead if().

server {
server_name www.new_server_name.com old_server_name.com;
return 301 $scheme://new_server_name.com$request_uri;
}

server {
        listen 10.15.1.2:80;
        server_name new_server_name.com;

 ... server staff...
}

But this doesn't work and first server {} directive MUST have listen directive as well.

 So, or I am do something wrong or wiki-page doesn't clear describe this situation?

--
Cheers,
  w



More information about the nginx mailing list