Forum Moderators: phranque

Message Too Old, No Replies

URL going into infinite loop when using proxypass and rewriterule

         

krish1

1:15 pm on Aug 8, 2012 (gmt 0)

10+ Year Member



Hi Everyone

I have a requirement where i need to make this URL

www.example.com/test1/test2/* look like
www.example.com/a/b/* in the address bar

For this i am writing this code in the config file,

ProxyPass /a/b/* www.example.com/test1/test2/*
ProxyPassReverse /a/b/* www.example.com/test1/test2/*

RewriteEngine on
RewriteRule ^/test1/test2/(.*) www.example.com/a1/a2/$1 [R,L]

after doing this, when i hit this url
www.example.com/test1/test2/* its getting converted to
www.example.com/a/b/* in the address bar, but

i am getting this message

server is redirecting the request for this address in a way that will never complete


Thanks in Advance

g1smd

6:28 pm on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have an infinite redirect loop.

Use the Live HTTP Headers extension for Firefox to examine the server response.

lucy24

10:30 pm on Aug 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's doing exactly what you told it to do. The ProxyPass rule says "when asked for /a/b/ show /test1/test2/" and the RewriteRule says "when asked for /test1/test2/ show /a/b/". It's like telling a robot to take a shovel and dig a hole. It will dig to China because you haven't told it when to stop digging.

Most but not all infinite loops can be stopped by a RewriteCond that looks at {THE_REQUEST}.

Is your error message coming from the server or the browser? In general, servers deal with internal-redirect errors while only browsers can stop external-redirect errors. But a Proxy is neither fish nor fowl.

I have a requirement where i need to make this URL

www.example.com/test1/test2/* look like
www.example.com/a/b/* in the address bar

For this i am writing this code in the config file,

ProxyPass /a/b/* www.example.com/test1/test2/*
ProxyPassReverse /a/b/* www.example.com/test1/test2/*

RewriteEngine on
RewriteRule ^/test1/test2/(.*) www.example.com/a1/a2/$1 [R,L]


Do you really want a temporary redirect? R alone defaults to 302, but you almost always want R=301.

Similarly, do you really need a Proxy at all? I kinda suspect you only need a Rewrite.