Looking at the Yii documentation today, we found that the recommended Nginx configuration parameters are:
Location/{
# Redirect everything that isn ' t a real file to index.php
Try_files $uri $uri//index.php$is_args$args;
}
Location ~ \.php$ {
Include Fastcgi_params;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass Unix:/var/run/php5-fpm.sock;
Try_files $uri = 404;
}
My local use of the original parameter configuration or: Rewrite ^/(. *) $/index.php/$1 last;
Rewrite is an Apache-like configuration
The configuration here is also easier to understand, but why is the official recommendation to recommend Try_files?
Finally I found an answer: Nginx is generally used in conjunction with FPM,
If you use rewrite to redirect all files and send them to php-fpm including static files, this configuration is not recommended now.
Reference: http://blog.wuxu92.com/nginx-rewrite-and-try-files/