英文:
HAProxy replace URL
问题
我有一个带有URL的域名:
https://example.com/browse/TEST-1
我需要在ha-proxy 2.0中将此URL更改为:
https://example.com/issue/TEST-1
我尝试了以下方式:
http-request replace-path ^([^\ :])\ /browse/(.) \1\ /issue/\2
http-request replace-path ^([^\ :])\ /browse/(.) \1\ /issue/\2
reqrep ^([^\ :])\ /browse/(.) \1\ /issue/\2
http-request replace-uri /browse/(.) /issue/\1
http-request replace-path ^/browse/(.) /issue/\1
我想不出来了,我做错了什么?
英文:
i have domain with URL:
https://example.com/browse/TEST-1
i need in ha-proxy 2.0 change this URL to:
https://example.com/issue/TEST-1
i try:
http-request replace-path ^([^\ :]*)\ /browse/(.*) \ /issue/
http-request replace-path ^([^\ :]*)\ /browse/(.*) \ /issue/
reqrep ^([^\ :]*)\ /browse/(.*) \ /issue/
http-request replace-uri /browse/(.*) /issue/
http-request replace-path ^/browse/(.*) /issue/
I'm out of ideas, what am I doing wrong?
答案1
得分: 0
不需要使用正则表达式处理这个。我相信在haproxy.cfg文件中添加以下内容就可以完成任务:
frontend http_front
bind *:80
bind *:443 ssl crt /path/to/ssl/certificate.pem
acl is_test1 path_beg /browse/TEST-1
http-request set-path /issue/TEST-1 if is_test1
英文:
No need to mess up with regex for this. I believe adding this on the haproxy.cfg file will do the job:
frontend http_front
bind *:80
bind *:443 ssl crt /path/to/ssl/certificate.pem
acl is_test1 path_beg /browse/TEST-1
http-request set-path /issue/TEST-1 if is_test1
答案2
得分: -1
这是一个参考。
这个模式将捕获元素,除了""/browse/""。
(.+?\/\/.+)\/.+\/(.+)
而且,您可以替换为,
/issue/
英文:
Here is a reference.
This pattern will capture the elements, except for "/browse/".
(.+?\/\/.+)\/.+\/(.+)
And, you can replace with,
/issue/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论