这个nginx的配置怎么写?

url1: "http://a.com/far/boo"
url2: "http://a.com/boo"

需求: 匹配到 /boo的都跳转到"http://b.com/test"
location匹配怎么写?

阅读 2.3k
3 个回答

试试这样写

location / {
  if (!-e $request_filename){
    rewrite /(boo|boo/.*)$ http://b.com/test break;
  }
  .....
 }
location /boo {
    proxy_pass http://b.com/test/;
}
location ~* /boo {
    return 301 http://b.com/test;
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题