nginx + php-fpm. How to rewrite? nginx + php-fpm. How to rewrite? nginx nginx

nginx + php-fpm. How to rewrite?


Use map directive to create a new request uri variable and then set fastcgi_param REQUEST_URI using this new variable. Tested and it works.

### update REQUEST_URImap $request_uri $new_request_uri {  default $request_uri;               # for frontend request, still use $request_uri  ~^/backend(?P<suffix>.*)$ $suffix;  # for backend request, only use the suffix after "/backend"}server {  ...  location ~ \.php$ {    include        fastcgi_params;    fastcgi_pass        127.0.0.1:9000;    fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;    fastcgi_param  REQUEST_URI        $new_request_uri;  }}