Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4754

Http redirect /foo/bar?a=b to /foo/bar/?a=b

$
0
0

Hello,

I’m trying to figure out what is the good way to redirect requests to add a trailing slash, while preserving the query string.

Found this in the documentation in : http://cbonte.github.io/haproxy-dconv/2.1/configuration.html#4.2-redirect%20prefix

First, it seems there is an error in the following example :

acl missing_slash path_reg ^/article/[^/]*$
redirect code 301 prefix / drop-query append-slash if missing_slash

it think there is a extra / that should be removed like this :

acl missing_slash path_reg ^/article[^/]*$
redirect code 301 prefix / drop-query append-slash if missing_slash

So that’s working (2nd version), but in my case I’d like to preserve the query, but if I remove ‘drop-query’, the append-slash is not behaving right.
I get redirected to something like /article?foo=bar/.

So in the documentation it states that we should only use append-slash in conjunction with drop-query.

But then, what’s the right way to redirect, adding a missing trailing slash on the path, preserving the querystring, and with a config that works for both HTTP1.1 and HTTP2 ?

Thanks!

Olivier

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4754

Trending Articles