0

以下の URL を PCRE と一致させるにはどうすればよいですか。

  1. http://www.test.com/abc?v=123&feature=True
  2. http://www.test.com/def?v=456&feature=True

私がやろうとしているのは、ドメインの下のパス (abc または def) を一致させて、nginx を使用して指定したホストにリクエストをリダイレクトできるようにすることです。

        #content of /etc/nginx/sites-enabled/default
             location / {
               #default redirect
                proxy_pass http://www.google.com;

               #redirect by domain name.
               if ($path ~* abc)
               {
                       proxy_pass http://10.1.1.47:8081?v=123&feature=True;
               }
               if ($path ~* edf)
               {
                       proxy_pass http://10.1.1.48:8081?v=456&feature=True;
               }
             }

PS: ドメインとパスは、それぞれ www.test.com と (abc|def) に限定されません。

ありがとう!

4

1 に答える 1

0
location / {
    proxy_pass http://www.google.com;
}

location /abc/ {
    proxy_pass http://10.1.1.47:8081?v=123&feature=True;
}

location /edf/ {
    proxy_pass http://10.1.1.48:8081?v=456&feature=True;
}
于 2012-05-31T19:48:10.530 に答える