Search code examples
regexhaproxypfsense

Remove from URL haproxy


I have an haproxy server and I need it to rewrite the URL.

For example, I have a url that is like this:

http://myserver.com/UserName/signalr/.....

and I need to remove the UserName, so when haproxy forwards to the server the url becomes:

http://myserver.com/signalr/.....

if I know the UserName then this works:

reqrep ^([^\ ]*\ /)UserName[/]?(.*)     \1\2

My problem is that the UserName is not a static, but always in the same place in the URL, directly after the domain.

Any help appreciated.


Solution

  • I did find a solution to this if anyone is interested

    reqrep ^([^)((?:[^\/]*\/){1}[^\/]*\/(.*)     \1\2