You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kenton Brede <kb...@gmail.com> on 2013/09/13 14:50:29 UTC

[users@httpd] Having issues with rewrite proxy rules, serving files to both old and new servers.

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."

Does anyone know why my "skip, proxy section" isn't working?  If there's a
better way, I'm all ears.  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/

-- 
Kent