- 使用vue开发完了移动端项目,现在要使用nginx部署
服务端多级域名,在nginx通过if+正则配备到对应的服务端
client, 也指定一个域名,如:www.xxx.com
client端有pad和手机端
if ($host = "www.xxx.com") {
if ($url = '/mobile') {
root /var/www/mobile/dist;
index index.html;
}
if ($url = '/ipad') {
root /var/www/pad/dist;
index index.html;
}
}
nginx 提示不能这样配置,有经验的老手,给点指点,怎么处理这种场景的配置
完全没必要判断$host,这个应该在
server_name
匹配index
指令不能放到if
里面,应该在server
或者location
块就配置好全局的index
root
可以放在location
里的if
但你这里完全没必要用
if
,使用location
和alias
即可似乎每一条配置指令都用错了……