How to remove extension with mor rewrite

Ninh Nguyen ninh.nv at gmail.com
Sat Nov 3 02:26:18 MSK 2007


It works like charm! Thank you! Great!

On Nov 3, 2007 2:33 AM, Igor Sysoev <is at rambler-co.ru> wrote:
>
> On Sat, Nov 03, 2007 at 01:40:18AM +0700, Ninh Nguyen wrote:
>
> > How to auto add .php after filename with this kind of url: download?a=x&b=y&....
> > and auto add index.php if we type www.domain.com/ or domain.com/
> > I tried but it does not work
> >
> > if (-f $request_filename/index.php) {
> >               rewrite (.*) $1/index.php break;
> >       }
> > if (-f $request_filename.php) {
> >               rewrite (.*) $1.php break;
> >       }
>
> Try the following:
>
>     server {
>
>        location = / {
>            rewrite  ^   /index.php  last;
>        }
>
>        location / {
>            if ($request_filename.php) {
>                rewrite (.*) $1.php   last;
>            }
>
>            root  ...;
>            ...
>        }
>
>        location ~ \.php$ {
>            proxy_pass   or  fastcgi_pass  ...
>            ...
>        }
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>



-- 
Ninh Viet Nguyen
ninh.nv at gmail.com
http://www.ninhnv.com





More information about the nginx mailing list