![NGINX-不同的网络路径到不同的文件夹](https://linux22.com/image/788567/NGINX-%E4%B8%8D%E5%90%8C%E7%9A%84%E7%BD%91%E7%BB%9C%E8%B7%AF%E5%BE%84%E5%88%B0%E4%B8%8D%E5%90%8C%E7%9A%84%E6%96%87%E4%BB%B6%E5%A4%B9.png)
我需要将不同的 Web 路径重定向到服务器上的不同文件夹。
http://test.local/site1/ => /srv/site_1/src/public
http://test.local/site2/ => /srv/site_2
尝试过这样的配置,但是没有用
server {
server_name test.local;
root /srv;
index index.html;
location /site1/ {
alias /srv/site_1/src/public;
try_files $uri $uri/ /index.php?$args;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location /site2/ {
alias /srv/site_2;
try_files $uri $uri/ /index.php?$args;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}