解决方案
hosts配置
hosts文件位置:C:\Windows\System32\drivers\etc
127.0.0.1 www.a.com
127.0.0.1 www.b.com
nginx配置
if ( $host = 'www.a.com') {
rewrite ^/api http://www.b.com/api?model=$arg_model&platformCode=$arg_platformCode?;
}
注意:如果尝试多次,未发生跳转,请清除浏览器缓存再试。
同时,在每次修改完配置后,记得重启一下nginx。
下面罗列一些nginx常用命令:(更多nginx命令请合理利用搜索引擎)
start nginx.exe #启动nginx
nginx.exe -s reload # 重载配置文件
nginx.exe -s stop # 关闭nginx
taskkill -f -im nginx* #暴力结束nginx进程