Hello nginx gurus,
First post but I have been reading this board for over a year!
My scenario:
I have many separate "sites" to run and they all use the same back end application(opencart). They also will be under the same domain, in folders. I don't want to duplicate the application code in each subdirectory.
I've got it working with a few sites and it works well. However, I will have ~200 sites soon.
Example sites:
domain.com/site1/
domain.com/site2/
etc...
My main code base is located at the root of domain.com.
I am currently using location rewrite blocks for each site.
That will get ugly when I have 200 sites, and a pain when I want to add new sites.
Can anyone help me with a "dynamic" configuration so I don't have to edit conf files each time?
===========================
server {
listen 80;
server_name domain.com;
root /etc/nginx/html/development;
error_log /var/log/nginx/dev.error.log;
index index.php;
rewrite ^([^.]*[^/])$ $1/ permanent; # trailing slash
# HERE IS THE CODE I WANT TO FIX
location ^~ /site1/ {
rewrite ^/site1/(.*) /$1;
}
location ^~ /site2/ {
rewrite ^/site2/(.*) /$1;
}
location ^~ /site3/ {
rewrite ^/site3/(.*) /$1;
}
}
=============================
Could I use map module, or possibly a single location regex?
Thanks!