Having set up multiple Kohana applications on Nginx, I need to adjust the "base url" parameter for each application. Before when I was using Apache with .htaccess
this was easy (RewriteBase
) but in Nginx I have found the following solution:
location /sites/site1/ {
try_files $uri /sites/site1/index.php?$args;
}
location /sites/site2/ {
try_files $uri /sites/site2/index.php?$args;
}
...etc...
Now, since I would like to add many more applications, I'd rather have a single location
block passing the Kohana application to the correct path. I've tried something like this (this won't work for me):
location /sites/([a-z0-9\-]+)/ {
try_files $uri /sites/$1/index.php?$args;
}
As you may see, I'm not a regex expert, but I want to pass any existing subdirectory with names containing alphanumerical characters and dash to the corresponding base path. Thanks.