1.前提如果web项目部署在 根目录下 即 /,需要同时启动两个项目即 web项目和h5项目
2。配置文件设置
location / {
root D:/nginx2/dist/;
index index.html index.htm;
try_files $uri $uri/ /index.html;
autoindex on; #开启nginx目录浏览功能
autoindex_exact_size off; #文件大小从KB开始显示
charset utf-8; #显示中文
add_header 'Access-Control-Allow-Origin' '*'; #允许来自所有的访问地址
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS'; #支持请求方式
add_header 'Access-Control-Allow-Headers' 'Content-Type,*';
}
#H5
location /h5 {
alias D:/h5/dist/;
index index.html index.htm;
try_files $uri $uri/ /h5/index.html;
}