HAProxy删除尾部斜杠

桑巴·夏尔马

我需要将所有网址重定向到不带斜杠的网址

例:

http://www.example.com/education/- > http://www.example.com/education

http://www.example.com/blah//- > http://www.example.com/blah

http://www.example.com/blah/blah///- > http://www.example.com/blah/blah

这是我现在拥有的:

frontend localnodes
    bind 127.0.0.1:80

    acl has_trailing_slash path_end  /
    reqrep ^(.*)[\ /]$ \1
    redirect prefix / code 301 if has_trailing_slash

参考:haproxy删除结尾的斜杠

但这只是使浏览器进入301s的重定向循环。我该如何实现?

阿鲁内什·辛格(Arunesh Singh)

您的正则表达式/最后只工作一个.*直到吃掉所有字符为止/

试试这个正则表达式:

^(.*?)[\/]+$ \1

.*? 使它在这里不贪婪。

[/]+ 一个或多个斜杠。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章