Now many RESTful frameworks, or frameworks that support pathinfo routing mode, will hide the entry file index.* in the URL. So, in this case, how to configure nginx so that it can determine whether the request is a dynamic request that requires program processing, or a static file request?
人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!
location /
{
index index.php;
# 重寫到index
if ($request_filename !~ (js|css|images|robots/.txt|index/.php.*) ) {
rewrite ^/(.*)$ /index.php/ last;
break;
}
}
server {
root /site/root;
location @cgi {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /site/root/index.php;
}
location / {
try_files $uri @cgi;
}
}