在网上查了许多解决方法,下面是自己测试过能行的方法,只需在nginx.conf文件添加内容就可以了.
打开nginx.conf文件
<span style="color: #000000;"> ## Try the requested URI as files before handling it to PHP. location </span>/<span style="color: #000000;"> { #在这里添加下面内容 root那里修改成自己站点的目录 location </span>/<span style="color: #000000;"> { root F:</span><span style="color: #ff0000;">/</span>study<span style="color: #ff0000;">/</span>wnmp<span style="color: #ff0000;">/</span>html; <span style="color: #000000;"> index index.html index.htm; #访问路径的文件不存在则重写URL转交给ThinkPHP处理 </span><span style="color: #0000ff;">if</span> ( !-<span style="color: #000000;">e $request_filename ) { rewrite </span>^<span style="color: #ff0000;">/</span>(.*)$ <span style="color: #ff0000;">/</span>index.php<span style="color: #ff0000;">/</span>$1 last; <span style="color: #0000ff;">break</span><span style="color: #000000;">; } } location </span>~ \.php<span style="color: #ff0000;">/</span>?.*$ { root F:<span style="color: #ff0000;">/</span>study<span style="color: #ff0000;">/</span>wnmp<span style="color: #ff0000;">/</span>html; fastcgi_pass 127.0.0.1:9001<span style="color: #000000;">; fastcgi_index index.php; #加载Nginx默认</span><span style="color: #ff0000;">"服务器环境变量"</span><span style="color: #000000;">配置 include fastcgi_params; include fastcgi.conf; #设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量 </span><span style="color: #0000ff;">set</span><span style="color: #000000;"> $fastcgi_script_name2 $fastcgi_script_name; </span><span style="color: #0000ff;">if</span> ( $fastcgi_script_name ~ <span style="color: #ff0000;">"^(.+\.php)(/.+)$"</span><span style="color: #000000;"> ) { </span><span style="color: #0000ff;">set</span> $fastcgi_script_name2 $1<span style="color: #000000;">; </span><span style="color: #0000ff;">set</span> $path_info $2<span style="color: #000000;">; } 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 </span>~* ^.+\.(jpg|jpeg|gif|png|bmp|css|js|<span style="color: #000000;">swf)$ { access_log off; root F:</span><span style="color: #ff0000;">/</span>study<span style="color: #ff0000;">/</span>wnmp<span style="color: #ff0000;">/</span>html; <span style="color: #0000ff;">break</span><span style="color: #000000;">; }</span>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks agoByDDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks agoByDDD
Roblox: Dead Rails - How To Tame Wolves
1 months agoByDDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks agoByDDD

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
