From: "Chris Arnold" <carn...@electrichendrix.com> To: users@httpd.apache.org Sent: Wednesday, April 24, 2013 3:21:25 PM Subject: Re: [users@httpd] Rewrite Rule
On Apr 24, 2013, at 2:00 PM, "Chris Arnold" wrote: > On Apr 23, 2013, at 8:39 PM, "Chris Arnold" wrote: > > > Apache 2.12.x on SLES11 SP2. We have a RDS server behind an apache server > > using proxypass. We need users to get to the RDS server using > > https://apps.domain.tld. The apache server should catch this request and > > send/rewrite to > > https://apps.domain.tld/rds/something/something/login.whatever. We have a > > ssl virtual host and in this virtual host i have a rewrite statement: > > > > RewriteEngine On > > RewriteCond %{HTTP_HOST} ^apps\. > > RewriteCond %{HTTPS} on > > RewriteRule ^/(.*) https://192.168.123.7/$1 [P] > > #RedirectMatch ^/$ /rds/something/something/login.whatever RewriteEngine On RewriteLog /var/log/apache2/rewrite.log RewriteLogLevel 3 RewriteCond %{HTTP_HOST} ^apps\. RewriteCond %{HTTPS} on RewriteRule ^/(.*) https://192.168.123.7/sub/ [R] OK, i have turned on rewrite log and this is what i get in the log: initial] (2) init rewrite engine with requested uri / /initial] (3) applying pattern '^/(.*)' to uri '/' /initial] (3) applying pattern '^/(.*)' to uri '/' /initial] (2) rewrite '/' -> 'https://192.168.123.7/rdweb/' /initial] (2) explicitly forcing redirect with https://192.168.123.7/rdweb/ /initial] (3) applying pattern '^/(.*)' to uri 'https://192.168.123.7/rdweb/' /initial] (1) escaping https://192.168.123.7/rdweb/ for redirect /initial] (1) redirect to https://192.168.123.7/rdweb/ [REDIRECT/302] As you can see this works fine. However, i am on the same network segment as 192.168.123.7 and the URL in the browser is https://192.168.123.7/sub/sub/sub/login.whatever and this does not/will not work when not on the same network segment. So i changed the rewriterule to: ^/(.*) https://apps.domain.tld: RewriteEngine On RewriteLog /var/log/apache2/rewrite.log RewriteLogLevel 3 RewriteCond %{HTTP_HOST} ^apps\. RewriteCond %{HTTPS} on RewriteRule ^/(.*) https://apps.domain.tld/sub/ [R] and this is in the rewrite log from the above: /initial] (2) init rewrite engine with requested uri /sub/ /initial] (3) applying pattern '^/(.*)' to uri '/syb/' /initial] (3) applying pattern '^/(.*)' to uri '/sub/' /initial] (2) rewrite '/sub/' -> 'https://apps.domain.tld/sub/' /initial] (2) explicitly forcing redirect with https://apps.domain.tld/sub/ /initial] (3) applying pattern '^/(.*)' to uri 'https://apps.domain.tld/sub/' /initial] (1) escaping https://apps.domain.tld/sub/ for redirect /initial] (1) redirect to https://apps.domain.tld/sub/ [REDIRECT/302] /initial] (2) init rewrite engine with requested uri /sub/ /initial] (3) applying pattern '^/(.*)' to uri '/sub/' /initial] (3) applying pattern '^/(.*)' to uri '/sub/' /initial] (2) rewrite '/sub/' -> 'https://apps.domain.tld/sub/' /initial] (2) explicitly forcing redirect with https://apps.domain.tld/sub/ /initial] (3) applying pattern '^/(.*)' to uri 'https://apps.domain.tld/sub/' /initial] (1) escaping https://apps.domain.tld/sub/ for redirect /initial] (1) redirect to https://apps.domain.tld/sub/ [REDIRECT/302] And this keeps repeating until i stop it. This looks like the rewrite loop but i am under the impression that by default max redirects=10 and should stop after 10. Any ideas as to what is going on with the rewrite statements?