try-files and Gallery3 rewriting
Igor Sysoev
igor at sysoev.ru
Thu Jun 9 12:10:51 MSD 2011
On Thu, Jun 09, 2011 at 11:39:55AM +0400, Igor Sysoev wrote:
> On Wed, Jun 08, 2011 at 11:43:16PM +0200, Andreas Lehr wrote:
> > Hiho,
> >
> > I am currently running gallery3 on nginx/php-fpm. Works like a charm so far.
> > But i'd like to get gallery3 also under the hood of try-files, but didn't
> > get it running up to now.
> >
> > The working (and evil) if rewrite code looks like this:
> >
> > location /gallery3/ {
> > if (!-e $request_filename) {
> > rewrite ^/gallery3/index.php/(.+)$
> > /gallery3/index.php?kohana_uri=$1 last;
> > rewrite ^/gallery3/(.+)$
> > /gallery3/index.php?kohana_uri=$1 last;
> > rewrite ^/gallery3/$ /gallery3/index.php?kohana_uri=/
> > last;
> > }
> >
> > }
> >
> > Could anybody supply a correct try_files directive and explain how and why
> > try_files should do the stuff in this case?
>
> It seems that "rewrite ^/gallery3/$ ..." is not used since "/gallery3"
> directory should exist.
>
> The way I prefer to use:
>
> location /gallery3/ {
>
> root /path/to/gallery3;
>
> location /gallery3/index.php/(.+)$ {
> try_files $uri /gallery3/index.php?kohana_uri=$1;
> }
>
> location /gallery3(/.+)$ {
> try_files $uri /gallery3/index.php?kohana_uri=$1;
> }
>
> location = /gallery3/index.php {
> fastcgi_pass backend;
> fastcgi_param SCRIPT_FILENAME /path/to/gallery3/index.php;
> include fastcgi_params;
> }
> }
Or better
location /gallery3/ {
root /path/to/gallery3;
location /gallery3/(index\.php/)?(.+)$ {
try_files $uri /gallery3/index.php?kohana_uri=$2;
}
location = /gallery3/index.php {
fastcgi_pass backend;
fastcgi_param SCRIPT_FILENAME /path/to/gallery3/index.php;
include fastcgi_params;
}
}
--
Igor Sysoev
More information about the nginx
mailing list