[Rewrite] Url - rewriting

CactO_o's nginx-forum at nginx.us
Fri Jul 31 06:40:59 MSD 2009


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 ?!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4619,4636#msg-4636






More information about the nginx mailing list