12 messages in ru.sysoev.nginxRe: nginx server redirect
FromSent OnAttachments
Kevin CastiglioneJun 19, 2009 10:44 pm 
Edho P AriefJun 19, 2009 11:17 pm 
Kevin CastiglioneJun 20, 2009 2:15 pm 
Kevin CastiglioneJun 20, 2009 2:17 pm 
Jim OhlsteinJun 20, 2009 7:52 pm 
Edho P AriefJun 20, 2009 10:04 pm 
Edho P AriefJun 20, 2009 10:18 pm 
Edho P AriefJun 20, 2009 10:30 pm 
Kevin CastiglioneJun 21, 2009 6:19 am 
Kevin CastiglioneJun 21, 2009 6:21 am 
Edho P AriefJun 21, 2009 7:31 am 
Kevin CastiglioneJun 21, 2009 11:37 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: nginx server redirectActions...
From:Kevin Castiglione (kevi@gmail.com)
Date:Jun 21, 2009 11:37:57 am
List:ru.sysoev.nginx

On Sun, Jun 21, 2009 at 7:32 AM, Edho P Arief <edho@gmail.com> wrote:

On Sun, Jun 21, 2009 at 8:21 PM, Kevin Castiglione<kevi@gmail.com> wrote:

On Sat, Jun 20, 2009 at 10:30 PM, Edho P Arief <edho@gmail.com>

wrote:

On Sun, Jun 21, 2009 at 12:19 PM, Edho P Arief<edho@gmail.com>

wrote:

here it is server { listen 80; server_name ~(.*)\.([^\.]*)\.([^\.]*)$; set $domain $2.$3; rewrite ^.* http://$domain$request_uri permanent; }

make sure that you have the server_name set on nginx or it'll redirect to .

can you tell how i set server_name on nginx for this to work?

create separate server block for each domain name

server { listen 80; server_name abcd.com; ... }

which will be used when nginx detects the domain as abcd.com

without this block, the redirection will go like this: NNN.abcd.com => abcd.com => . (dot)

with this it'll access correct site instead (stop at abcd.com)

is it possible to do this with just one server block for multiple domains: for ex: server { listen 80; server_name .abcd.com .efgh.com .ijkl.com .. }