httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenton Brede <kbr...@gmail.com>
Subject [users@httpd] Trouble with serving local content while using RewriteRule [P]
Date Fri, 13 Sep 2013 16:40:38 GMT
I'm trying to write rules that will serve files on the new server, while
proxying files that don't exist, to the old server.  The proxy rules work
fine, sending missing files and directories to the old server.

The problem I'm having is http://new-server.example.com/blah (/blah/ exists
on the new server) is passed through to the proxy rules and routed to the
old server.

The reason for attempting the skip is because
http://new-server.example.com/blah falls through to the "proxy section" and
passes http://new-server.example.com/blah/index.php.  Index.php doesn't
exist on the new server, index.html does.  The "proxy section" doesn't
follow all the index file possibilities in DirectoryIndex, it just looks at
the first one.

So I end up with error message, "The requested URL /blah/index.php was not
found on this server."

How can this be written so it actually works? --  Thanks.

RewriteEngine On
# skip, proxy section
RewriteCond /var/www/html%{REQUEST_FILENAME}     -f  [OR]
RewriteCond /var/www/html%{REQUEST_FILENAME}     -d
RewriteRule .? - [S=4]

# proxy section
RewriteCond /var/www/html%{REQUEST_FILENAME}       !-f
RewriteCond /var/www/html%{REQUEST_FILENAME}       !-d
RewriteRule ^/(.*) http://old-server.example.com/$1 [P]
ProxyPassReverse / http://old-server.example.com/


# rewrite log
pass through /index.php
init rewrite engine with requested uri /
applying pattern '.?' to uri '/'
RewriteCond: input='/var/www/html/' pattern='-f' => not-matched
RewriteCond: input='/var/www/html/' pattern='-d' => matched
pass through /
init rewrite engine with requested uri /index.php
applying pattern '.?' to uri '/index.php'
RewriteCond: input='/var/www/html/index.php' pattern='-f' => matched
pass through /index.php
init rewrite engine with requested uri /blah/
applying pattern '.?' to uri '/blah/'
RewriteCond: input='/var/www/html/blah/' pattern='-f' => not-matched
RewriteCond: input='/var/www/html/blah/' pattern='-d' => matched
pass through /blah/
init rewrite engine with requested uri /blah/index.php
applying pattern '.?' to uri '/blah/index.php'
RewriteCond: input='/var/www/html/blah/index.php' pattern='-f' =>
not-matched
RewriteCond: input='/var/www/html/blah/index.php' pattern='-d' =>
not-matched
applying pattern '^/(.*)' to uri '/blah/index.php'
RewriteCond: input='/var/www/html/blah/index.php' pattern='!-f' => matched
RewriteCond: input='/var/www/html/blah/index.php' pattern='!-d' => matched
rewrite '/blah/index.php' -> 'http://old-server.example.com/blah/index.php'
forcing proxy-throughput with http://old-server.example.com/blah/index.php
go-ahead with proxy request proxy:
http://old-server.example.com/blah/index.php [OK]

-- 
Kent

Mime
View raw message