Rewriting all subdomains to one in particular.[Solved]

Saimon Moore saimonmoore at gmail.com
Fri Jan 19 20:30:11 MSK 2007


Of course, it's a lot clearer..

perfect..thanks

On 1/19/07, Igor Sysoev <is at rambler-co.ru> wrote:
>
> On Fri, 19 Jan 2007, Saimon Moore wrote:
>
> > Thanks for the recommendations,
> >
> > I've now come up with this final config:
> >
> > http://pastie.caboo.se/34269
>
> You should not use
>
>      if ($http_host != "mydomain.com") {
>
> because there more clear way:
>
>      server {
>          server_name  mydomain.com;
>          root /var/www/apps/mydomain.com/current/public;
>          ...
>      }
>
>      server {
>          server_name  some.mydomain.com *.mydomain.com;
>          rewrite  ^(.*) http://www.mydomain.com$1  permanent;
>      }
>
> > On 1/19/07, Igor Sysoev <is at rambler-co.ru> wrote:
> >>
> >> On Fri, 19 Jan 2007, Saimon Moore wrote:
> >>
> >> > Found the solution. Stupidity on my part. :)
> >> >
> >> > Thanks anyway...
> >> >
> >> >         if ($server_name !~ "^(www\.)?mydomain\.com") {
> >> >           rewrite  ^/(.*)$  http://www.mydomain.org/$1  permanent;
> >> >         }
> >>
> >> Look the recommendations about *.mydomain.com separation:
> >>
> >> http://comments.gmane.org/gmane.comp.web.nginx.english/548
> >> http://comments.gmane.org/gmane.comp.web.nginx.english/551
> >>
> >> > On 1/19/07, Saimon Moore <saimonmoore at gmail.com> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I have a nginx config with 4 virtual hosts.
> >> >>
> >> >> Specifically I have the following server_name declarations in my
> >> virtual
> >> >> hosts:
> >> >>
> >> >> #VH1
> >> >> server_name es.mydomain.com;
> >> >>
> >> >> #VH2
> >> >> en.mydomain.com;
> >> >>
> >> >> #VH3
> >> >> fr.mydomain.com;
> >> >>
> >> >> #VH4
> >> >> mydomain.com *.mydomain.com;
> >> >>
> >> >> What I'd like to do is rewrite any request for VH4 (i.e. not
> >> >> es/en/fr.mydomain.com) to :
> >> >>
> >> >> www.mydomain.com
> >> >>
> >> >> So if a request comes in for wwww.mydomain.com I'd like to rewrite
> it
> >> to
> >> >> www.mydomain.com/$request_filename
> >> >>
> >> >> I've tried a few things but haven't managed to get it right.
> >> >>
> >> >> My latest try:
> >> >>
> >> >> #In VH4 server declaration
> >> >> location /
> >> >> {
> >> >>   if ($host !~ "/^(www\.)?amicsmuseuprecolombi\.org/") {
> >> >>     rewrite  (.*)  http://www.amicsmuseuprecolombi.org$1  permanent;
> >> >>   }
> >> >> }
> >> >>
> >> >>
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Saimon
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Saimon Moore
> >> > Freelance Web Developer
> >> > (Available for hire - For details visit http://saimonmoore.net)
> >> >
> >> > Skype: saimonmoore
> >> > Yahoo IM: saimonmoore
> >> > Google IM: saimonmoore
> >> >
> >>
> >> Igor Sysoev
> >> http://sysoev.ru/en/
> >>
> >>
> >
> >
> > --
> > Saimon Moore
> > Freelance Web Developer
> > (Available for hire - For details visit http://saimonmoore.net)
> >
> > Skype: saimonmoore
> > Yahoo IM: saimonmoore
> > Google IM: saimonmoore
> >
>
> Igor Sysoev
> http://sysoev.ru/en/
>
>


-- 
Saimon Moore
Freelance Web Developer
(Available for hire - For details visit http://saimonmoore.net)

Skype: saimonmoore
Yahoo IM: saimonmoore
Google IM: saimonmoore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20070119/81d5a289/attachment.html>


More information about the nginx mailing list