Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache http请求haproxy剪切字符串_Apache_Http_If Statement_Xmlhttprequest_Haproxy - Fatal编程技术网

Apache http请求haproxy剪切字符串

Apache http请求haproxy剪切字符串,apache,http,if-statement,xmlhttprequest,haproxy,Apache,Http,If Statement,Xmlhttprequest,Haproxy,我有一个关于haproxy中http请求的问题。我有以下问题 我有一个可变的url,例如 http://mywebsite.com/job/1/hello-world/display/redirect http://mywebsite.com/和 /display/redirect 可以是可变的。现在,我希望所有转到。…/display/redirect的内容都被切断,以便转到http://mywebsite.com/job/1/hello-world没有/display/redirect有

我有一个关于haproxy中http请求的问题。我有以下问题

我有一个可变的url,例如

http://mywebsite.com/job/1/hello-world/display/redirect
http://mywebsite.com/

/display/redirect
可以是可变的。现在,我希望所有转到。
…/display/redirect
的内容都被切断,以便转到
http://mywebsite.com/job/1/hello-world
没有/display/redirect有什么方法可以定义它?我有可能定义固定URL,但如何定义可变URL,其中只有结尾始终符合原则

我一直在想这样的事情:

http-request redirect code 301 location http://mywebsite.com/ [..] if {path_beg [..]/display/redirect}
您询问了以模式结尾的路径,因此您不会使用
path\u beg
(路径以开头)--您会使用
path\u end
(路径以结尾)进行匹配

然后使用
path
fetch和
regsub()
转换器在删除模式的情况下重写路径。使用
regsub()
需要HAProxy 1.6或更高版本

http-request redirect code 301 location %[path,regsub(/display/redirect$,)] if { path_end /display/redirect }