如何在NGINX中继续进行位置匹配?

我在(虚拟)服务器上设置了fastcgi_cache 。 但是,我想closures文件夹wp-admin和文件wp-login.phpcaching。 configuration的问题是当文件夹或文件匹配时,它不会将请求传递给PHP,而NGINX服务于.php文件。 (我已经简化了configuration文件,所以它不是太大。)

 fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=cache:30m; fastcgi_cache_key "$scheme$host$uri$is_args$args"; server { ... fastcgi_cache cache; fastcgi_cache_valid 200 10m; location / { index index.html index.php; } location ~* ^/wordpress/(wp-login\.php|wp-admin) { fastcgi_cache off; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

问题在于,PHP从/wordpress/wp-login.php获取请求。 这个问题怎么解决?

试试这个:

 location ~* ^/wordpress/(wp-login\.php|wp-admin) { fastcgi_cache off; location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }