I want to change the root for location /testing.
How can I do this?
This is what I have in the middle of this server stanza, yet the testing
reseller is served from the live root.
index index.php index.html index.htm;
root /home/ian/websites/coachmaster/htsecure;
# move root for testing reseller
location /testing {
root /home/ian/websites/coachmaster/testing;
}
# take resellers off the front of path to rs=reseller param
rewrite ^/(kaleidoscope|chat|Spanish|3MCoach|testing)(.*)$ $2?rs=$1
last;
# php to fastcgi
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param HTTPS ON;
include /etc/nginx/fastcgi_params;
}
I was actually hoping to switch the root on a per-reseller basis,
perhaps by testing for a file I can âtouchâ or delete to switch to the
new configuration, but I canât think how to do that.
Thanks
Ian
(Sorry if this is a duplicate - the first did not appear).
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?
In the regexp location the document_root is inherited from the server
context.
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.
root /home/ian/websites/coachmaster/htsecure;
rewrite ^/(?kaleidoscope|chat|Spanish|3MCoach|testing)(.*)$
$2?rs=$reseller last;
I donât understand what the ? bit is doing. (and Google has
been no help!).
On Wed, Aug 01, 2012 at 11:30:08AM +0100, Ian H. 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 (Module ngx_http_core_module), 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 ^/(?kaleidoscope|chat|Spanish|3MCoach|testing)(.*)$
$2?rs=$reseller last;
I donât understand what the ? 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.