01. 打开配置文件 vhosts.conf
02. 在 location 下添加如下代码
1 if (!-e $request_filename) { 2 rewrite ^/(.*)$ /index.php/$1 last; 3 break; 4 }
03. 完整配置如下 (可参照)
1 server { 2 listen 80; 3 server_name www.tp5.com; 4 root "D:/PHPDemo/tp5/public"; 5 location / { 6 if (!-e $request_filename) { 7 rewrite ^/(.*)$ /index.php/$1 last; 8 break; 9 } 10 index index.php index.html error/index.html; 11 error_page 400 /error/400.html; 12 error_page 403 /error/403.html; 13 error_page 404 /error/404.html; 14 error_page 500 /error/500.html; 15 error_page 501 /error/501.html; 16 error_page 502 /error/502.html; 17 error_page 503 /error/503.html; 18 error_page 504 /error/504.html; 19 error_page 505 /error/505.html; 20 error_page 506 /error/506.html; 21 error_page 507 /error/507.html; 22 error_page 509 /error/509.html; 23 error_page 510 /error/510.html; 24 include D:/PHPDemo/tp5/public/nginx.htaccess; 25 autoindex off; 26 } 27 location ~ \.php(.*)$ { 28 fastcgi_pass 127.0.0.1:9000; 29 fastcgi_index index.php; 30 fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 31 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 32 fastcgi_param PATH_INFO $fastcgi_path_info; 33 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 34 include fastcgi_params; 35 } 36 }
标签:index,PHPStudy,nginx,TP5,html,error,php,page,fastcgi From: https://www.cnblogs.com/jieling/p/16827089.html