How to change the root for testing

Francis Daly francis at
Wed Aug 1 18:45:28 UTC 2012

On Wed, Aug 01, 2012 at 11:30:08AM +0100, Ian Hobson wrote:
> On 30/07/2012 16:19, leki75 wrote:

Hi there,

> >Do you mean that requesting /testing/something.php tries to use
> >/home/ian/websites/coachmaster/htsecure/something.php instead of
> >/home/ian/websites/coachmaster/testing/something.php?
> Yes, Exactly.

> >In the regexp location the document_root is inherited from the server
> >context.
> I expected that to be replaced as the location is more specific. Oh well.

One request is handled by one location.

You have the location definitions:

  location /testing {}
  location ~ \.php$ {}

Per the docs (, the request for
/testing/something.php is handled by the second location there.

What you want is some way of setting "fastcgi_param SCRIPT_FILENAME"
to point to the testing filename, when appropriate.

Probably the least-impact way of doing this would be to add a new

  location ~ ^/testing/.*php$ {}

with the same content as your current php location, plus the root
directive that you want. There are other ways of doing this too.

> >rewrite ^/(?<reseller>kaleidoscope|chat|Spanish|3MCoach|testing)(.*)$
> >$2?rs=$reseller last;
> I don't understand what the ?<reseller> bit is doing.  (and Google has 
> been no help!).

It's a perl-compatible regex named capture. Older pcre libraries may
not recognise the syntax, in which case you should see a clear warning
to that effect.

All the best,

Francis Daly        francis at

More information about the nginx mailing list