Equivalent to Apache's RewriteCond %{HTTP:Accept-Language} / RewriteRule wanted #2130
-
We're replacing Apache with YARP and searching for a YARP equivalent to the following Apache directives: RewriteCond %{HTTP:Accept-Language} ^(ja|pt-BR).$ [NC] Is this possible with JSON configuration only (I could not find a solution) or must be done programmatically? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The JSON config doesn't let you capture values from headers to use in the path right now. If you only wanted to do this for a few languages, you can try something like this, where you define a separate route depending on the "Routes": {
"catchAll": {
"ClusterId": "myCluster",
"Match": {
"Path": "{**catch-all}"
}
},
"help-ja": {
"ClusterId": "myCluster",
"Match": {
"Path": "/svc/help/{**remainder}",
"Headers": [
{ "Name": "Accept-Language", "Values": [ "ja" ], "Mode": "Contains" }
]
},
"Transforms": [
{ "PathPattern": "/svc/help/ja/{**remainder}" }
]
},
"help-ptBR": {
"ClusterId": "myCluster",
"Match": {
"Path": "/svc/help/{**remainder}",
"Headers": [
{ "Name": "Accept-Language", "Values": [ "pt-BR" ], "Mode": "Contains" }
]
},
"Transforms": [
{ "PathPattern": "/svc/help/pt-BR/{**remainder}" }
]
}
} but it may end up being easier to do the transformation via code. |
Beta Was this translation helpful? Give feedback.
The JSON config doesn't let you capture values from headers to use in the path right now.
If you only wanted to do this for a few languages, you can try something like this, where you define a separate route depending on the
Accept-Language
header value: