Перенаправление обработки скрипта в другую папку
server{listen 192.168.1.1:80;server_name site.ztc ;root /home/site.ztc/httpdocs/app/frontend/web;indexindex.php;access_log /home/site.ztc/logs/access.log;error_log /home/site.ztc/logs/error.log error;charset utf-8; # With PHP-FPMlocation / {indexindex.php;try_files$uri$uri/ /index.php?$query_string;} # PHP fastcgilocation~ \.php {include fastcgi_params;# Use your own port of fastcgi here#fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/var/run/php-fpm-7-site.ztc.sock;fastcgi_indexindex.php;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;} # rpclocation ^~ /rpc {alias /home/site.ztc/httpdocs/app/api/web;indexindex.php;try_files$uri$uri/ @rpc; # PHP fastcgilocation~* \.php {include fastcgi_params;# Use your own port of fastcgi here#fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/var/run/php-fpm-7-site.ztc.sock;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param SCRIPT_FILENAME $request_filename;}} location@rpc{rewrite ^/rpc/(.*)$ /rpc/index.php?$1 last;# THIS IS THE IMPORTANT LINE}# end rpc }
- @rpc - Этот локейшен необходим для перенаправления c /rpc на /rpc/index.php. Указываем lastдля отключения дальнейшего реврайта
- $request_filename - равносильно fastcgi_param SCRIPT_FILENAME /home/site.ztc/httpdocs/app/api/web/$script;