Hello Jürgen I have what is below which as I say seems to work and redirects to /something when /de/something is provided and at the bottom I have a couple of tests.
I've also put the response back in the list as I must have clicked reply not reply to all. frontend http bind 192.168.0.99:80 transparent mode http acl url_de path_beg /de use_backend de-backend if url_de default_backend web-backend backend web-backend balance roundrobin server web1 192.168.0.50:80 check backend de-backend http-response add-header X-Via TEST reqirep "^([^\ :]*)\ /de/(.+)" "\1\ /\2" server web1 192.168.0.50:80 maxconn 100 Test1 to / [root@home etc]# curl -i 192.168.0.99/ HTTP/1.1 200 OK Date: Thu, 27 Oct 2016 09:57:50 GMT Server: Apache/2.4.23 (Fedora) OpenSSL/1.0.2j-fips PHP/5.6.26 X-Powered-By: PHP/5.6.26 Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 <!DOCTYPE html> <!--[if IE 9 ]><html class="ie ie9" lang="en" class="no-js"> <![endif]--> <!--[if !(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> ..... rest of html page is displayed Test2 to /de/index.php [root@home etc]# curl -i 192.168.0.99/de/ HTTP/1.1 200 OK Date: Thu, 27 Oct 2016 09:58:49 GMT Server: Apache/2.4.23 (Fedora) OpenSSL/1.0.2j-fips PHP/5.6.26 X-Powered-By: PHP/5.6.26 Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 X-Via: TEST <!DOCTYPE html> <!--[if IE 9 ]><html class="ie ie9" lang="en" class="no-js"> <![endif]--> <!--[if !(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> ..... rest of html page is displayed You will note the X-Via is inserted and I get the same content as the first request as /de is removed so I just get index.php >From what I can see if you have a redirect, Ie 301 its not going to be the same as the URL rewrite and ive not figured out how to do that while keeping everything else below /de/this/that/request as /this/that/request. X-Bogosity: Unsure, tests=bogofilter, spamicity=0.500000, version=1.2.4 I see the rule works and does as intended if you goto /de it gets re-written to / I hope that helps? I am not sure there is much more I can share here with regard your request. Regards Andrew Smalley Loadbalancer.org Ltd. On 27 October 2016 at 10:21, Jürgen Haas <[email protected]> wrote: > Hi Andrew, > > I'm responding directly as your message went to my email directly and > not through the forum. > > I'm now using this rule: > > > backend backend_test > > reqirep "^([^\ :]*)\ /de/(.+)" "\1\ /\2" > > http-response add-header X-Via TEST > > server server_test 1.2.3.4:80 maxconn 100 > > Then I use > > > curl -I http://test.arocom.de/de/team > > which is certainly not caching and the response is this: > > > HTTP/1.1 404 Not Found > > Date: Thu, 27 Oct 2016 09:07:03 GMT > > Server: Apache > > Content-Type: text/html; charset=iso-8859-1 > > X-Via: TEST > > This indicates that HaProxy is forwarding the request to the server and > does not respond with a 301. This is a fact just because of: > > - The header X-Via is only set by this rule, so it ends up there > - The "Server: Apache" shows that the response comes from the server > > So, if you're getting a 301, I guess it is not triggered by reqrep. It > must be something different. > > Any idea? > > > Thanks > Jürgen > > Am 27.10.2016 um 10:50 schrieb Andrew Smalley: > > Hello Jürgen > > > > In my tests the reqrep or reqirep (case insensitive) did the job of > > changing the address bar URL . > > > > I went to http://www.example.com/de/this/page.html > > > > Then the page / url changed to > > > > > > http://www.example.com/this/page.html > > > > I had to do this a few times in a private browser session and after > > clearing my cache a few times because the previous test was cached which > > was really annoying while trying to establish which rule works. > > > > The last one I provided seemed to do the job and if you want to add it > > into an ACL you know what the rewrite rule is now. > > > > Regards > > > > Andrew Smalley > > > > Loadbalancer.org Ltd. > > > > > > > > On 27 October 2016 at 07:40, Jürgen Haas <[email protected] > > <mailto:[email protected]>> wrote: > > > > Hi Andrew, > > > > You mean just the reqrep line on its own does the redirect? Because > if > > not I would then require the redirect line in addition which then > would > > cause that loop. > > > > Or is your approach just forwarding the corrected URi to the backend > > such that it deals with the that and responds as if the original > request > > were to that URI? That's not what I need. I really need a redirect > with > > a 301 such that users will see that new URL in their browser's > address > > bar and also search engines should "learn" about that corrected > > structure. > > > > Yours > > Jürgen > > > > Am 25.10.2016 um 16:24 schrieb Andrew Smalley: > > > Hello Jürgen > > > > > > Thank you for your reply saying its the same line you already have > > > > > > I did this on a single VIP assuming you just wanted to rewrite /de > to / > > > and have everything below /de/page-x become /page-x > > > > > > If this is the case it works well and does not produce a redirect > loop. > > > > > > Try it out and see how it works on its own. > > > > > > > > > > > > Regards > > > > > > Andrew Smalley > > > > > > Loadbalancer.org Ltd. > > > > > > > > > > > > On 25 October 2016 at 15:18, Jürgen Haas > > > <[email protected] > > <mailto:[email protected]> > > > <mailto:[email protected] > > <mailto:[email protected]>>> wrote: > > > > > > Thanks Andrew, > > > > > > That's the same regex that I have in my backend definition. > But I also > > > need the ACLs to make sure that the redirect only happens on a > specific > > > host and with a specific beginning of a path. Otherwise that > would be > > > redirected every time and end up in an infinite loop, doesn't > it? > > > > > > Thanks > > > Jürgen > > > > > > Am 25.10.2016 um 15:47 schrieb Andrew Smalley: > > > > Hello Jürgen > > > > > > > > Sorry for the delay in replying to you. > > > > > > > > after a little playing I have come up with this single line > without an > > > > ACL which seems to do what you want. > > > > > > > > It will redirect http://domain.com/de/this/that/other/dir > > <http://domain.com/de/this/that/other/dir> > > > <http://domain.com/de/this/that/other/dir > > <http://domain.com/de/this/that/other/dir>> > > > > > > > > > > > > To > > > > > > > > http://domain.com/this/that/other/dir > > <http://domain.com/this/that/other/dir> > > > <http://domain.com/this/that/other/dir > > <http://domain.com/this/that/other/dir>> > > > > > > > > > > > > reqrep ^([^\ :]*)\ /de/(.*) \1\ /\2 > > > > > > > > Regards > > > > > > > > Andrew Smalley > > > > > > > > Loadbalancer.org Ltd. > > > > > > > > > > > > > > > > On 25 October 2016 at 10:35, Jürgen Haas > > > > <[email protected] > > <mailto:[email protected]> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>> > > > > <mailto:[email protected] > > <mailto:[email protected]> > > > <mailto:[email protected] > > <mailto:[email protected]>>>> > wrote: > > > > > > > > Hi Andrew, > > > > > > > > just not having luck with this. Here is my rule which is > certainly used > > > > when e.g. calling https://www.arocom.de/de/team but it > doesn't redirect > > > > to https://www.arocom.de/team > > > > > > > > Any idea what's wrong? > > > > > > > > backend backend_aweb2_https > > > > acl r_host hdr(host) -i -n www.arocom.de < > http://www.arocom.de> > > > <http://www.arocom.de> <http://www.arocom.de> > > > > acl r_path path_beg /de/ > > > > reqirep "^([^\ :]*)\ /de/(.+)" "\1\ /\2" if r_host > r_path > > > > redirect prefix / code 301 if r_host r_path > > > > http-response add-header X-Via aweb2 > > > > server server_aweb2 1.2.3.4:80 <http://1.2.3.4:80> < > http://1.2.3.4:80> > > > <http://1.2.3.4:80> maxconn 100 > > > > > > > > Thanks > > > > Jürgen > > > > > > > > > > > > Am 24.10.2016 um 11:23 schrieb Andrew Smalley: > > > > > Hello Jürgen > > > > > > > > > > In that case I think you will want something like > > > > > > > > > > > > > > > |acl de_url path_beg /de reqrep ^([^\ :]*)\ > /de/\d+/(.+)/? \1\ /\2 > > > > > redirect prefix / code 301 if de_url | > > > > > > > > > > > > > > > > > > > > Regards > > > > > > > > > > Andrew Smalley > > > > > > > > > > Loadbalancer.org Ltd. > > > > > > > > > > > > > > > > > > > > On 24 October 2016 at 10:19, Jürgen Haas > > > > > <[email protected] > > <mailto:[email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>> > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public. > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public.>.gmane.org > > <http://gmane.org> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>>> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public. > gmane.org > > <mailto:[email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>> > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>>>>> > > > > wrote: > > > > > > > > > > Hi Andrew, > > > > > > > > > > Thanks for your quick reply and yes, I'm using the > manual almost daily. > > > > > But my question is not covered, I guess. > > > > > > > > > > Also your example is not working as it is always > redirecting to the > > > > > front page, but we would require wildcards. > > > > > > > > > > Examples: > > > > > > > > > > http://www.example..com/de/page-one > > > <http://www.example.com/de/page-one < > http://www.example.com/de/page-one>> > > > <http://www.example.com/de/page-one < > http://www.example.com/de/page-one> > > > <http://www.example.com/de/page-one > > <http://www.example.com/de/page-one>>> > > > > > <http://www.example.com/de/page-one > > <http://www.example.com/de/page-one> > > <http://www.example.com/de/page-one > > <http://www.example.com/de/page-one>> > > > > <http://www.example.com/de/page-one < > http://www.example.com/de/page-one> > > > <http://www.example.com/de/page-one > > <http://www.example.com/de/page-one>>>> => > > > > > http://www.example.com/page-one < > http://www.example.com/page-one> > > <http://www.example.com/page-one <http://www.example.com/page-one>> > > > > <http://www.example.com/page-one < > http://www.example.com/page-one> > > > <http://www.example.com/page-one > > <http://www.example.com/page-one>>> <http://www.example.com/page-one > > <http://www.example.com/page-one> > > > <http://www.example.com/page-one <http://www.example.com/page- > one>> > > > > <http://www.example.com/page-one < > http://www.example.com/page-one> > > <http://www.example.com/page-one <http://www.example.com/page-one > >>>> > > > > > http://www.example..com/de/page-two > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two>> > > > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two> > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two>>> > > > > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two> > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two>> > > > > <http://www.example.com/de/page-two < > http://www.example.com/de/page-two> > > > <http://www.example.com/de/page-two > > <http://www.example.com/de/page-two>>>> => > > > > > http://www.example.com/page-two < > http://www.example.com/page-two> > > <http://www.example.com/page-two <http://www.example.com/page-two>> > > > > <http://www.example.com/page-two < > http://www.example.com/page-two> > > > <http://www.example.com/page-two > > <http://www.example.com/page-two>>> <http://www.example.com/page-two > > <http://www.example.com/page-two> > > > <http://www.example.com/page-two <http://www.example.com/page- > two>> > > > > <http://www.example.com/page-two < > http://www.example.com/page-two> > > <http://www.example.com/page-two <http://www.example.com/page-two > >>>> > > > > > > > > > > In other words, we just want to remove the "/de" > subsctring from the > > > > > URL. Is that possible? > > > > > > > > > > > > > > > Thanks > > > > > Jürgen > > > > > > > > > > > > > > > > > > > > Am 24.10.2016 um 11:00 schrieb Andrew Smalley: > > > > > > Hello Jürgen > > > > > > > > > > > > Below is a link to the haproxy manual which will > tell you exactly what > > > > > > you wish to know. > > > > > > > > > > > > https://www.haproxy.com/doc/ > aloha/7.0/haproxy/http_redirection.html > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html > > > > > > > <https://www..haproxy.com/doc/aloha/7.0/haproxy/http_ > redirection.html > > <http://haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html>> > > > > > > > > > <https://www.haproxy.com/doc/aloha/7..0/haproxy/http_ > redirection.html <https://www.haproxy.com/doc/aloha/7..0/haproxy/http_ > redirection.html> > > > <https://www.haproxy.com/doc/aloha/7..0/haproxy/http_ > redirection.html > > <https://www.haproxy.com/doc/aloha/7..0/haproxy/http_ > redirection.html>>> > > > > > <https://www.haproxy.com/doc/ > aloha/7.0/haproxy/http_redirection.html > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html > > > > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_ > redirection.html > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html > >> > > > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_ > redirection.html > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html > > > > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_ > redirection.html > > <https://www.haproxy.com/doc/aloha/7.0/haproxy/http_redirection.html > >>>> > > > > > > > > > > > > and something like this will be what you are > looking to do > > > > > > > > > > > > |acl is_de path_beg -i /de acl is_domain > hdr(host) -i www.domain.com <http://www.domain.com> <http://www.domain.com > > > > <http://www.domain.com> > > > <http://www.domain.com> > > > > > > <http://www.domain.com> redirect code 301 > location > > > > > > http://www.domain.com/ if is_domain is_de| > > > > > > > > > > > > > > > > > > > > > > > > Regards > > > > > > > > > > > > Andrew Smalley > > > > > > > > > > > > Loadbalancer.org Ltd. > > > > > > > > > > > > > > > > > > > > > > > > On 24 October 2016 at 09:53, Jürgen Haas > > > > > > <jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public. > gmane.org > > <mailto:[email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>> > > > > > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>>> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public>. > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A@public>.>.gmane.org > > <http://gmane.org> > > > <http://gmane.org> > > > > > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>>>> > > > > > > > > > <mailto:[email protected] > > <mailto:[email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]>> > > > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]> > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>>> > > > > > > > > > > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A- > [email protected]> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>> > > > > > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]> > > > > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected] > > <mailto:jurgenhaas-m5I1DM4ARil35hdLjg3A3A-XMD5yJDbdMReXY1tMh2IBg- > [email protected]>>>>>> > > > > > wrote: > > > > > > > > > > > > Hi all, > > > > > > > > > > > > one of my clients is looking for a wildcard > > > redirect to > > > > get redirects > > > > > > from www.example.com/de/* > > <http://www.example.com/de/*> > > > <http://www.example.com/de/*> <http://www.example.com/de/*> > > > > <http://www.example.com/de/*> > > > > > <http://www.example.com/de/*> to > > > > > > www.example.com/* <http://www.example.com/*> > > <http://www.example.com/*> > > > <http://www.example.com/*> > > > > <http://www.example.com/*> > > > > > <http://www.example.com/*> > > > > > > > > > > > > I know how to do just the opposite, but for > > this one I > > > > > couldn't find a > > > > > > solution in the documentation. > > > > > > > > > > > > Any chance that can be done? > > > > > > > > > > > > > > > > > > Thanks > > > > > > Jürgen > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > http://www.paragon-es.de > http://about.me/jurgenhaas > >

