server{listen*:80;server_nameadmin.hiphop.top;location/{root"D:\Office\PHPStudy\PHPTutorial\WWW\MyWork\VhiphopAdmin\dist";indexindex.html;try_files$uri$uri//index.html;}location/api{root"D:\Office\PHPStudy\PHPTutorial\WWW\MyWork\VhiphopAdminApi\public";indexindex.php;try_files$uri$uri//index.php?$query_string;}location~\.php(.*)${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_split_path_info^((?U).+\.php)(/?.+)$;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}}配置代码如上访问admin.hiphop.top可以匹配到"D:OfficePHPStudyPHPTutorialWWWMyWorkVhiphopAdmindist"访问admin.hiphop.top/api不能匹配到"D:OfficePHPStudyPHPTutorialWWWMyWorkVhiphopAdminApipublic"dist目录是我的前端静态文件,public目录是phpapi接口的入口目录请问如何配置才能做到访问admin.hiphop.top/*时匹配dist目录并且访问admin.hiphop.top/api优先匹配php的public目录配置2个域名是没问题的因为浏览器有跨域问题,所以现在想只用一个域名
2 回答
九州编程
TA贡献1785条经验 获得超4个赞
问题已经解决了在最后一个.php匹配规则里面加上root就可以了location~\.php(.*)${root"D:\Office\PHPStudy\PHPTutorial\WWW\MyWork\VhiphopAdminApi\public";indexindex.php;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_split_path_info^((?U).+\.php)(/?.+)$;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}
添加回答
举报
0/150
提交
取消