server { // 这个在windows 下配置是ok的,linux 下不知道是否可以生效! 待后续验证 listen 8999; server_name localhost; location / { root D:/phpstudy_pro/WWW/tp5/public; // 这里是tp5 public 入口文件 index index.html index.htm; try_files $uri $uri/ /index.php?s=$uri&$args; // 表示
#如果请求不是文件或目录,则将uri交给index.php处理,同时保留参数
if ( !-e $request_filename) { rewrite ^(.*)$ /index.php/?s=$1 last; //进行URL重写,将默认访问URL中的index.php?s=通过rewrite隐藏 break; } } location ~ \.php(.*)$ { root D:/phpstudy_pro/WWW/tp5/public; //tp5 入口文件 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
上图: