在網上查了許多解決方法,下面是自己測試過能行的方法,只需在nginx.conf文件添加內容就可以了.
打開nginx.conf文件
## Try the requested URI as files before handling it to PHP. location / { #在這裡添加下面內容 root那裡修改成自己站點的目錄 location / { root F:/study/wnmp/html; index index.html index.htm; #訪問路徑的文件不存在則重寫URL轉交給ThinkPHP處理 if ( !-e $request_filename ) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php/?.*$ { root F:/study/wnmp/html; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; #加載Nginx默認"服務器環境變量"配置 include fastcgi_params; include fastcgi.conf; #設置PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME服務器環境變量 set $fastcgi_script_name2 $fastcgi_script_name; if ( $fastcgi_script_name ~ "^(.+\.php)(/.+)$" ) { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; } #最後這部分是為了css和js 以及圖片等資源 location ~* ^.+\.(jpg|jpeg|gif|png|bmp|css|js|swf)$ { access_log off; root F:/study/wnmp/html; break; }