下面有两种方法,选择其中一种就行。
server { listen 80; server_name wordpress.com; #自己的域名 root "D:\phpStudy\PHPTutorial\WWW\wordpress"; #项目目录 location / { # 第一种方法 #if (-f $request_filename/index.html){ # rewrite (.*) $1/index.html break; #} #if (-f $request_filename/index.php){ # rewrite (.*) $1/index.php; #} #if (!-f $request_filename){ # rewrite (.*) /index.php; #} # 第二种方法 try_files $uri $uri/ /index.php?$args ; proxy_read_timeout 300; index index.php index.html index.htm; } location ~ \.php(.*)$ { 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; } }