我需要将不同的 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;
}
}