[Rewrite] Url - rewriting

Igor Sysoev is at rambler-co.ru
Fri Jul 31 13:26:36 MSD 2009


On Thu, Jul 30, 2009 at 10:40:59PM -0400, CactO_o's wrote:

> Igor Sysoev Wrote:
> -------------------------------------------------------
> > On Thu, Jul 30, 2009 at 01:23:52PM -0400,
> > CactO_o's wrote:
> > 
> > > Hi all,
> > > 
> > > In first, i'm french and I don't speak english
> > very well, so I hope you understand me =] 
> > > 
> > > So, I want redirect the Html page to index.php
> > with GET argument, in this model :
> > > 
> > > http://www.domaine.tlm/.html =>
> > http://www.domaine.tlm/index.php?page=
> > > 
> > > I have do that  
> > > 
> > > 
> > > server 
> > > {
> > > [...]
> > >         location ~ .html$ {
> > >                 rewrite ^/(.*).html$
> > /index.php?page=$1;
> > >         }
> > > }
> > > 
> > > 
> > > Another, I want rewrite the sub-domain if host
> > ISN'T address IP :
> > > 
> > > http://.domaine.tlm/ =>
> > http://www.domaine.tlm/?sd=
> > > 
> > > For example,
> > > 
> > > - if  is html page :
> > > http://.domaine.tlm/example.html =>
> > http://www.domaine.tlm/index.php?sd=&page=exemple
> > > 
> > > - if  is php script : 
> > > http://.domaine.tlm/php/script.php?arg=get =>
> > http://www.domaine.tlm/php/script.php?sd=&arg=get
> > > 
> > > So I have write that  
> > > 
> > > 
> > > server
> > > {
> > >         location / {
> > >                 root   /var/www/kreatoo;
> > >                 index  index.html index.htm
> > index.php;
> > > 
> > >                 if ( $host !~* 
> > "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
> > )
> > >                 {
> > >                          if ( $host ~*
> > "(.*)\.*\.{2,4}" )
> > >                          {
> > >                                  set $sd $1;
> > >                                 rewrite ^(.*)$
> > http://www.domaine.tlm/index.php?sd=$sd
> > >                          }
> > >                 }
> > >         }
> > > 
> > >         [...]
> > > }
> > > 
> > > 
> > > But don't functionality !
> > > 
> > > Can you help me please ?
> > > 
> > > Thank you all !
> > 
> > server {
> >     server_name  domain.tlm;
> > 
> >     location / {
> >         rewrite ^/(.*).html$
> > http://www.domain.tlm/index.php?sd=&page=$1;
> >     }
> > 
> >     location /php/ {
> >         rewrite ^/(.*).html$
> > http://www.domain.tlm/index.php?sd=;
> >     }
> > 
> >     return 404;
> > }
> > 
> > server {
> >     server_name  www.domain.tlm;
> > 
> >     location ~ \.html$ {
> >         rewrite ^/(.*).html$
> > http://www.domain.tlm/index.php?page=$1;
> >     }
> > 
> >     ...
> > }
> > 
> > 
> > -- 
> > Igor Sysoev
> > http://sysoev.ru/en/
> 
> Thank you for help but can you explain me what you do ?!

The configuration above does required redirects.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list