I dynamic number of Joomla installations in subfolders of the domain.
For example:
http://site/joomla_1/
http://site/joomla_2/
http://site/joomla_3/
...
Currently I have the follwing config that works:
index index.php;
location / {
index index.php index.html index.htm;
}
location /joomla_1/ {
try_files $uri $uri/ /joomla_1/index.php?q=$uri&$args;
}
location /joomla_2/ {
try_files $uri $uri/ /joomla_2/index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm/joomla.sock;
...
}
I'm trying to combine joomla_N rules in one:
location ~ ^/(joomla_[^/]+)/ {
try_files $uri $uri/ /$1/index.php?q=$uri&$args;
}
but server starts to return index.php as is (does not call the php-fpm).
It looks like the nginx stops the processing of the regex rules after the first match.
Is there any way to combine this rules with something like regex?
Let's understand things:
http://wiki.nginx.org/HttpCoreModule#location
So first regex stop searching!
http://wiki.nginx.org/HttpCoreModule#try_files
So the last parameter of the
try_files
is an internal url on which the chain is reinvoked if no static file is found.So answer 1 works because the
.php$
regexp is matched only when the internal redirect is invoked on the url, insteadjoomla_[^/]
is matching always also on the internal php url.To understand better also this works on a shell:
nginx:
User urls:
Put the .php location first, and then put this after: