handling subdirectories location

Thiago Farina tfransosi at gmail.com
Mon Jun 8 23:08:10 UTC 2015


Hi Francis,

First, thanks for replying.

On Mon, Jun 8, 2015 at 7:46 PM, Francis Daly <francis at daoine.org> wrote:
> On Mon, Jun 08, 2015 at 02:07:54PM -0300, Thiago Farina wrote:
>
> Hi there,
>
>> What I'm trying to do is something like the following:
>>
>> http://domainame.com/site1/index.php
>> http://domainame.com/site2/index.php
>> http://domainame.com/site3/index.php
>
> In nginx, one request is handled in one location.
>
> See http://nginx.org/r/location, for example, for the rules by which
> one location is chosen.
>
> In this case, you probably want one
>
>   location ^~ /site1/ {}
>
> block, plus one
>
>   location ^~ /site2/ {}
>
> block; and nested in those, one or more blocks which relate to requests
> which should be handled by php.
>
> If you want "every request should be handled by /site1/index.php",
> you write one configuration. If you want "every request that ends
> in .php should be handled by a matching file", you write a different
> configuration. If you want "every request that ends in .php, or that
> includes the string '.php/', should be handled by a matching file,
> you write yet another configuration.
>
> From what I've read in these mails, I'm afraid that I do not know what
> exactly it is that you want.
>
> For example: does "/foo/index.php/secure/login" refer to exactly that
> request; or to any request that starts with "/foo/index.php/;", or to
> any request that starts with "/foo/" and does not exactly name a file
> on the filesystem; or to something else?
>
>
> Possibly something like
>
>   root /var/www/html;
>   include fastcgi.conf;
>   location ^~ /site1/ {
>     location ~ \.php($|/) {
>       fastcgi_split_path_info (.*.php)(/.*);
>       fastcgi_pass unix:php.sock;
>     }
>   }
>   location ^~ /site2/ {
>     location ~ \.php($|/) {
>       fastcgi_split_path_info (.*.php)(/.*);
>       fastcgi_pass unix:php.sock;
>     }
>   }
>
As you suggested I tried the following config:
server {
    listen       80;
    server_name  domainame.com;

    root /data/www/domainame.com;
    include fastcgi.conf;

    location ^~ /gocart/ {
      location ~ \.php($|/) {
        fastcgi_split_path_info (.*.php)(/.*);
        fastcgi_pass   127.0.0.1:9000; #unix:/var/run/php5-fpm.sock;
      }
    }
}

But when I navigate to http://domainame.com/gocart nginx returns 403 Forbidden.

Basically what I'm trying to do is to run gocart
(https://gocartdv.com) and phorum (www.phorum.org) in
domainame.com/gocart and domainame.com/forum (they are in
/data/www/domainname.com/gocart/ and /data/www/domainame.com/forum).

-- 
Thiago Farina



More information about the nginx mailing list