나는 이런의 nginx 서버 구성이 있습니다일치하는 위치를 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;
}
}
을하고 그것을 작동합니다. 하지만 regex (코드에 따라)를 사용하여 동적으로 처리하려고하면 URL을 브라우저에 표시하는 대신 다운로드합니다.
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;
}
}
어떤 생각?