nginx server redirect

Kevin Castiglione kevincastiglione at gmail.com
Sun Jun 21 22:38:20 MSD 2009


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

> On Sun, Jun 21, 2009 at 8:21 PM, Kevin
> Castiglione<kevincastiglione at gmail.com> wrote:
> > On Sat, Jun 20, 2009 at 10:30 PM, Edho P Arief <edhoprima at gmail.com>
> wrote:
> >>
> >> On Sun, Jun 21, 2009 at 12:19 PM, Edho P Arief<edhoprima at 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
 ..
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090621/5b3ed596/attachment.html>


More information about the nginx mailing list