配置Demo
server {
server_name adminapi-local.activity.com;
root D:\WWW\project\activity-api\public;
index index.php index.html;
access_log /data/log/nginx/lottery-$host.log;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /admin.php?pathinfo=$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
fastcgi_param LOTTERY_ENV dev;
}
}
路由到項目根目錄時的處理
location / {
}
請求網站下PHP文件的時候,反向代理到cgi
location ~ .php(.*)$ {
}
https://blog.csdn.net/zjuwangleicn/article/details/79300347
當訪問的文件和目錄不存在時,重定向到某個php文件
if( !-e $request_filename )
{
rewrite ^/(.*)$ index.php last;
}
https://www.linuxidc.com/Linux/2014-01/95493.htm
服務配置指令
listen 80 監聽端口
server_name www.test.com 主機host
root /data/html 根目錄
index index.php index.html 首頁
location / {} 根目錄路由