简体   繁体   中英

Rewrite rule on application gateway azure

i would like to implement a rewrite rule on my Application Gateway v2 or other way if exist on Azure.

On application gateway i setup 2 path based rule for our main site that i call mywebsite.it deployed to webapp1:

1- if i reach mywebsite.it/function* it redirect traffic correctly to webapp2;

2- if i reach from mywebsite.it/myapplication*, for example mywebsite.it/myapplication/images/xyz the application start with mywebsite.it/function*. This rule point also to webapp2;

I would like to do this for scenario 2. From mywebsite.it/myapplication/images/xyz, apply a rewrite that change only /myapplication/, for example mywebsite.it/function/images/xyz. I need to mantain the path after function/* in rewrite operation(it is not static and change every time a user make a request when they pass from mywebsite.it/myapplication* )

I tried to configure the rewrite but it didn't work:

在此处输入图像描述

在此处输入图像描述

I can't try evaluate path map, becouse in our http setting applied to path base rules(is the same becouse web app is the same), override backend path is enabled with /. Without it application didn't work.

Any help is really appreciated

Would suggest you to please set the correct value for “Pattern to match” and “URL path value” and create the require object for HTTP header rewrite as it has stated according to the below Microsoft document. As it seems you have set wrong value for “Pattern to match” and “URL path value”.

Refer this: https://learn.microsoft.com/en-us/azure/application-gateway/rewrite-http-headers-portal

The pattern to match is a regular expression. In regular expressions, the forward slash ("/") is a reserved character so it must be escaped with a backslash (""), so it should look like ("/"). Use regex101.com to test your regular expression and ensure that you get a match when you expect it and no match when you do not expect it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM