我有nginx + php-fpm,当我尝试访问'/ rest / proccess'时,我想要$ _SEVER ['REQUEST_URI'] =='/ process'。所以我刚为nginx创建了这样的配置:
location /rest/ {
root /var/www/php;
rewrite ^/rest/(.*)$ /$1 break;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include fastcgi_params;
}
但它不起作用,在php我有$ _SEVER ['REQUEST_URI'] =='/ rest / process'。
我做错了什么?
日Thnx
UPD:似乎重写规则只重写$ document_uri,而不是$ request_uri,所以$ _SEVER ['REQUEST_URI'] =='/ rest / process'和$ _SEVER ['DOCUMENT_URI'] =='/ process'
答案 0 :(得分:0)
我认为您需要将重写更改为:
rewrite ^/rest/(.+)$ $scheme://$host/$1;