J'ai une configuration de serveur nginx comme ceci:Comment utiliser l'emplacement correspondant en tant que variable dans le bloc de serveur Nginx?
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm;
server_name example.com www.example.com;
location /project1/public {
try_files $uri $uri/ /project1/public/index.php?$query_string;
}
location /project2/public {
try_files $uri $uri/ /project2/public/index.php?$query_string;
}
location /project3/public {
try_files $uri $uri/ /project3/public/index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
et il fonctionne. Mais quand j'essaie d'utiliser regex (code suivant) pour le faire dynamiquement, il télécharge l'URL au lieu de l'afficher dans le navigateur.
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm;
server_name example.com www.example.com;
location ~ ^/([^/]+)/public {
try_files $uri $uri/ /$1/public/index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
Une idée?