"transparent" option of the "bind" keyword.
-redirect {location | prefix} <to> [code <code>] {if | unless} <condition>
+redirect location <to> [code <code>] {if | unless} <condition>
+redirect prefix <to> [drop-query] [code <code>] {if | unless} <condition>
Return an HTTP redirection if/unless a condition is matched
May be used in sections : defaults | frontend | listen | backend
no | yes | yes | yes
response. There are currently two types of redirections : "location" and
"prefix". With "location", the exact value in <to> is placed into the HTTP
"Location" header. With "prefix", the "Location" header is built from the
- concatenation of <to> and the URI. It is particularly suited for global site
+ concatenation of <to> and the URI. If the optional "drop-query" keyword is
+ used in a prefix-based redirection, then the location will be set without any
+ possible query-string, which is useful for directing users to a non-secure
+ page for instance. The "prefix" mode is particularly suited for global site
redirections.
The code is optional. It indicates in <code> which type of HTTP redirection
acl clear dst_port 80
acl secure dst_port 8080
acl login_page url_beg /login
- redirect prefix https://mysite.com if login_page !secure
- redirect location http://mysite.com/ if !login_page secure
+ acl uid_given url_reg /login?userid=[^&]+
+ redirect prefix https://mysite.com if login_page !secure
+ redirect prefix http://mysite.com drop-query if login_page !uid_given
+ redirect location http://mysite.com/ if !login_page secure
See section 2.3 about ACL usage.
int type = REDIRECT_TYPE_NONE;
int code = 302;
char *destination = NULL;
+ unsigned int flags = REDIRECT_FLAG_NONE;
cur_arg = 1;
while (*(args[cur_arg])) {
return -1;
}
}
+ else if (!strcmp(args[cur_arg],"drop-query")) {
+ flags |= REDIRECT_FLAG_DROP_QS;
+ }
else if (!strcmp(args[cur_arg], "if")) {
pol = ACL_COND_IF;
cur_arg++;
rule->rdr_len = strlen(destination);
rule->type = type;
rule->code = code;
+ rule->flags = flags;
LIST_INIT(&rule->list);
LIST_ADDQ(&curproxy->redirect_rules, &rule->list);
}
acl url_test1 url_reg test1
acl url_test2 url_reg test2
+ acl url_test3 url_reg test3
redirect location /abs/test code 301 if url_test1
redirect prefix /pfx/test code 302 if url_test2
- redirect prefix /pfx/test code 303 if url_test2
+ redirect prefix /pfx/test code 303 drop-query if url_test3
### unconditional redirection
#redirect location https://example.com/ if TRUE