You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**ReplacePrefixMatch is NOT supported** in `RequestRedirect` due to ALB limitations. ALB redirect actions cannot preserve path suffixes during prefix replacement.
323
+
324
+
❌ **This configuration will be rejected:**
325
+
```yaml
326
+
apiVersion: gateway.networking.k8s.io/v1
327
+
kind: HTTPRoute
328
+
metadata:
329
+
name: unsupported-redirect
330
+
namespace: example-ns
331
+
spec:
332
+
parentRefs:
333
+
- name: my-gateway
334
+
rules:
335
+
- matches:
336
+
- path:
337
+
type: PathPrefix
338
+
value: /old-prefix
339
+
filters:
340
+
- type: RequestRedirect
341
+
requestRedirect:
342
+
path:
343
+
type: ReplacePrefixMatch
344
+
replacePrefixMatch: /new-prefix # NOT SUPPORTED
345
+
```
346
+
347
+
✅ **Alternative 1: Use URLRewrite for path transformations** (performs internal rewrite before forwarding to backend):
348
+
```yaml
349
+
apiVersion: gateway.networking.k8s.io/v1
350
+
kind: HTTPRoute
351
+
metadata:
352
+
name: rewrite-example
353
+
namespace: example-ns
354
+
spec:
355
+
parentRefs:
356
+
- name: my-gateway
357
+
rules:
358
+
- matches:
359
+
- path:
360
+
type: PathPrefix
361
+
value: /old-prefix
362
+
filters:
363
+
- type: URLRewrite
364
+
urlRewrite:
365
+
path:
366
+
type: ReplacePrefixMatch
367
+
replacePrefixMatch: /new-prefix # SUPPORTED
368
+
backendRefs:
369
+
- name: my-service
370
+
port: 80
371
+
```
372
+
373
+
✅ **Alternative 2: Use ReplaceFullPath for static redirects**:
374
+
```yaml
375
+
apiVersion: gateway.networking.k8s.io/v1
376
+
kind: HTTPRoute
377
+
metadata:
378
+
name: redirect-example
379
+
namespace: example-ns
380
+
spec:
381
+
parentRefs:
382
+
- name: my-gateway
383
+
rules:
384
+
- matches:
385
+
- path:
386
+
type: PathPrefix
387
+
value: /old-path
388
+
filters:
389
+
- type: RequestRedirect
390
+
requestRedirect:
391
+
path:
392
+
type: ReplaceFullPath
393
+
replaceFullPath: /new-path # SUPPORTED
394
+
statusCode: 301
395
+
```
396
+
397
+
**Key Differences:**
398
+
- `RequestRedirect`: Returns HTTP 301/302 redirect response to client
399
+
- `URLRewrite`: Transforms the path internally before forwarding to backend (no redirect visible to client)
Copy file name to clipboardExpand all lines: pkg/gateway/routeutils/route_rule_action.go
+2-8Lines changed: 2 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -216,7 +216,7 @@ func buildHttpRuleRedirectActionsBasedOnFilter(filters []gwv1.HTTPRouteFilter, r
216
216
casegwv1.HTTPRouteFilterURLRewrite:
217
217
continue
218
218
default:
219
-
returnnil, errors.Errorf("Unsupported filter type: %v. Only request redirect is supported. To specify header modification, please configure it through LoadBalancerConfiguration.", filter.Type)
219
+
returnnil, errors.Errorf("Unsupported filter type: %v. To specify header modification, please configure it through LoadBalancerConfiguration.", filter.Type)
returnnil, errors.Errorf("ReplacePrefixMatch is not supported in RequestRedirect filters. ALB redirect actions cannot preserve path suffixes during prefix replacement. Use URLRewrite filter with ReplacePrefixMatch for path transformations, or use ReplaceFullPath in RequestRedirect for static path redirects")
0 commit comments