使用TP5做为项目后台接口,在二级目录下配置nginx
1、首先,你要确保在不配置二级目录的情况下,可以通过浏览器访问到。例如:http://www.example.com/End/public/index.php?s=index/index/index
2、将下面一location 进行二级目录增加修改
server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html/member/; index index.html index.php # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } ####这里进行修改 location /End/public/{ index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^/End/public/(.*)$ /End/public/index.php?s=$1 last; } } ####### error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } }