server {
listen *:80;
server_name admin.hiphop.top;
location / {
root "D:\Office\PHPStudy\PHPTutorial\WWW\MyWork\VhiphopAdmin\dist";
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
root "D:\Office\PHPStudy\PHPTutorial\WWW\MyWork\VhiphopAdminApi\public";
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
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;
include fastcgi_params;
}
}
configuration code as above
access admin.hiphop.top
can match to "D:OfficePHPStudyPHPTutorialWWWMyWorkVhiphopAdmindist"
access admin.hiphop.top/api
cannot match to "D:OfficePHPStudyPHPTutorialWWWMyWorkVhiphopAdminApipublic"
the dist directory is my front-end static file, and the public directory is the entry directory of the php api interface
how to configure it to match the dist directory when accessing admin.hiphop.top/*
and to access the admin.hiphop.top/api first match the public directory of php
it"s okay to configure two domain names because the browser has cross-domain problems, so now you want to use only one domain name