views:

102

answers:

1

Hi,

Basically I have 2 separate code bases, v1 and v2 for the sake of this example. I want to redirect a certain area of the v1 site to v2 so we can periodically port the old code to new code.

Now, I have done this exact sort of code porting before, I just can't remember the exact specifics and whether we did some apache voodoo to get it to work. This time round I can get it to hit the v2 code but then subsequent requests use the v1 vhost and so the images v2 are requesting are translating to v1's path and do not exist.

So I want domain1.com/foo/bar to get redirected to the v2 codebase, in the v1 vhost (under /home/domain1) I have:

RewriteRule ^/foo/?([0-9a-zA-Z]*)/?(([0-9a-zA-Z/]*))$ /home/domain2/index.php?controller=foo&action=$1&params=$2 [NC,L]

This successfully catches the request and passes it to the v2 codebase, but then the v2 codebase continues to use the v1 vhost. Obviously I would like it to hit the v2 codebase and start to use that vhost, but without using an external redirect [R]

The output from the rewrite log is as follows:

192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (2) init rewrite engine with requested uri /foo
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (3) applying pattern '^/foo/?([0-9a-zA-Z]*)/?(([0-9a-zA-Z/]*))$' to uri '/foo'
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (2) rewrite '/foo' -> '/home/domain2/index.php?controller=foo&action=&params='
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (3) split uri=/home/domain2/index.php?controller=foo&action=&params= -> uri=/home/domain2/index.php, args=controller=foo&action=&params=
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (2) local path result: /home/domain2/index.php
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#81783540/initial] (1) go-ahead with /home/domain2/index.php [OK]
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#8175e4b0/initial] (2) init rewrite engine with requested uri /images/layouts/standard/header/header_logo.gif
192.168.1.64 - - [23/Apr/2009:17:04:11 +0100] [domain1.com/sid#813071d0][rid#8175e4b0/initial] (3) applying pattern '^/foo/?([0-9a-zA-Z]*)/?(([0-9a-zA-Z/]*))$' to uri '/images/layouts/standard/header/header_logo.gif'
...
...

Can anyone help with the last step!?

+1  A: 

If you want to make a proxy call to another server, add P to the flags.

Lucero
Thanks, but this doesn't work correctly and I don't remember using the P flag last time I did it.
jmoz
You have to have a full URL (including protocol) for the new source basically like you would have with a redirect. However, the web server is not sending a redirect but doing the request itself, which makes it a reverse proxy.
Lucero