gateway-api icon indicating copy to clipboard operation
gateway-api copied to clipboard

Allow Redirects to Drop Trailing Slash

Open robscott opened this issue 2 years ago • 16 comments

What would you like to be added: A way to configure a redirect to drop a trailing slash.

Why this is needed: Today our redirect filter makes it seem like this should maybe be possible, for example this gets kinda close:

kind: HTTPRoute
metadata:
  name: http-filter-redirect
spec:
  hostnames:
  - example.com
  rules:
  - matches:
    - path:
        type: Exact
        value: /example/
    filters:
    - type: RequestRedirect
      requestRedirect:
        statusCode: 302
        path:
          type: ReplaceFullPath
          replacePrefixMatch: /example

Unfortunately an implementation of this config might result in a redirect loop depending on what we decide in https://github.com/kubernetes-sigs/gateway-api/issues/1953. Even if it did work, it's still not as easy as it should be to do that. At a minimum, we should clarify whether this works. We should also consider providing a better more scalable way to do this even if this way may technically work.

robscott avatar Apr 19 '23 14:04 robscott