浏览文章
文章信息
Nginx代理|反向代理|nginx 截断请求参数|移动端和PC之间访问跳转|if 多条件判断
10359
# set $flag 'is'; # user_agentif ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) { set $flag "${flag}_mobile"; } # restApi if ($request_uri ~* ^/rest){ set $flag "${flag}_rest_api"; } # paypalif ($request_uri ~* ^/customapi/transparent/response){ set $flag "${flag}_custom_transparent_response"; } # paypalif ($request_uri ~* ^/paypal/transparent/cancel){ set $flag "${flag}_custom_transparent_cancel"; } # downloadable if ($request_uri ~* ^/downloadable){ set $flag "${flag}_downloadable"; } # graphql if ($request_uri ~* ^/graphql){ set $flag "${flag}_graphql_api"; } # media if ($request_uri ~* ^/media){ set $flag "${flag}_media"; } # if ($request_uri ~* ^/ecpaysdk){ set $flag "${flag}_ecpaysdk"; } # if ($request_uri ~* ^/map){ set $flag "${flag}_map"; } # api#if ($request_uri ~* ^/api){ # set $flag "${flag}_api"; #} # m.aiweline.com set $mu 0; if ($flag = "is_mobile"){ set $mu "${mu}1"; } if ($request_uri ~* ^/customer/account/createPassword){ set $mu "${mu}2"; } if ($mu = "01"){ rewrite ^(.*) http://m.aiweline.com.tw$2 redirect;# permanent:301 redirect:302 } if ($mu = "012"){ rewrite ^(.*) http://m.aiweline.com.tw/reset$2 redirect;# permanent:301 redirect:302 } # #if ($flag = "is_mobile_api"){ # rewrite ^/(.*)/api(.*)$ http://www.aiweline.com$2 permanent; #} # #if ($flag = "is_mobile_rest_api"){ # rewrite ^(.*)$ http://www.aiweline.com$1 permanent; #}