nginx域名如何定位到项目的某个目录下?

2025-04-27 21:31:43
推荐回答(1个)
回答1:

server {

listen       80 default_server;

server_name  test.example.com;

root F:/web;

access_log  logs/access.log  main buffer=1024k;

}

Nginx 设置三个域名在同一目录下:

server {

listen 80 ; 

server_name http://a.com http://b.com http://c.com ; 

location / { 

root /home/website ; 

if ($host = "http://a.com"){

set $index index.html ; 

}

if ($host = "http://b.com"){

set $index index.php ; 

}

if ($host = "http://c.com"){

set $index default.php ; 

}

index $index ;

}

}