server { listen 80; server_name www.baidu.com; root "xxx/frontend"; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With,Authorization,Content-Type,access-token,bloc-id,store-id; add_header Access-Control-Allow-Methods GET,POST,OPTIONS,PUT,DELETE; location / { index index.php index.html error/index.html; error_page 400 /error/400.html; include D:/nginx.htaccess; autoindex off; } location ~ \.php(.*)$ { fastcgi_pass 192.168.0.1; fastcgi_index index.php; } location /api { index index.php index.html; if (!-e $request_filename) { rewrite ^/api/(.*)$ /api/index.php last; } if (!-f $request_filename){ set $rule_0 1$rule_0; } } location /admin { index index.php index.html; if (!-e $request_filename) { rewrite ^/admin/(.*)$ /admin/index.php last; } if (!-f $request_filename){ set $rule_0 1$rule_0; } } location /help { index index.php index.html; if (!-e $request_filename) { rewrite ^/help/(.*)$ /help/index.php last; } if (!-f $request_filename){ set $rule_0 1$rule_0; } } } 还有一个问题 我看这里写了3个 index index.php index.html 这种写3个代表了什么 是按照顺序找么? nginx.htaccess 好像是这个 if (!-f $request_filename){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite /.* /index.php; }