[root@centos8 ~]#vim /apps/nginx/conf/conf.d/mobile.conf
server {
listen 80;
server_name www.a.com;
location / {
root "/data/nginx/html/mobile";
index index.html;
rewrite / http://www.b.com redirect;
}
}
server {
listen 80;
server_name www.b.com;
location / {
root "/nginx/html/";
index index.html;
}
}
[root@centos8 ~]#echo 111 > /data/nginx/html/mobile/index.html
[root@centos8 ~]#echo 222 > /nginx/html/index.html
[root@centos8 ~]#vim /etc/hosts
10.0.0.150 www.a.com www.b.com
[root@centos8 ~]#curl www.a.com
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>
[root@centos8 ~]#curl -L www.a.com
222