[SOLVED] G1 -> G2 rewrite problems when trying to migrate & move to separate G2 website.

ivan_bev

Joined: 2006-04-10
Posts: 14
Posted: Tue, 2007-01-16 19:08

I am having a problem when migrating from G1 to G2 with the URL rewrite of G1 URLs to G2 URLs.

Any (useful ;) )suggestions gratefully accepted! It appears to be purely rewrite issues (rather than any other configuration).

I am moving my website ( http://www.dreamtime.org/ ) to a new machine and, as part of the migration, I am trying to upgrade my photo gallery from G1 to G2. In addition I want to move it from it's current place of http://www.dreamtime.org/photos/ to something like http://photos.dreamtime.org/photos/ (with or without the trailing /photos - I'm as-yet undecided). I have G2 multisite running fine on the new machine (with G2 sites running for a few friends).

I have copied the website across, including the albums et al from the old machine, created a G2 multisite installation for http://photos.dreamtime.org/photos/ and imported a single "simple" album .. the latest one ( http://www.dreamtime.org/photos/lgi-xmas-2006 ). This imported fine, and the import page mentioned adding 151 rewrite entries for the migration.

I have added the rewrite command into the apache config for www.dreamtime.org on the new machine (DNS is not pointing at it) as specified in the instructions, but tweaked for a redirect to the new website:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  Rewritecond %{REQUEST_FILENAME} !gallery_remote2.php
  RewriteRule (.*)$ http://photos.dreamtime.org/photos/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]
</IfModule>

I then add a suitable entry to my hosts file so it uses the new machine for http://www.dreamtime.org/ and try to access the old URL for the G1 gallery:
http://www.dreamtime.org/photos/lgi-xmas-2006

This fails ... but what happens is that (according to the apache logs) the rewrite-rule appends the full path to the "short URL", which migrate.Redirect does not recognise, so it doesn't work:

81.168.23.219 - - [16/Jan/2007:17:55:57 +0000] "GET /main.php?g2_controller=migrate.Redirect&g2_path=/var/www/hosts/www.dreamtime.org/docs/photos/lgi-xmas-2006 HTTP/1.1" 404 206 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" 0 photos.dreamtime.org

(also, for some reason it removes the "/photos" at the beginning of the URL).

For the sake of confirmation, I did some hacks with aliases etc so that I could access the photos.dreamtime.org gallery directory from www.dreamtime.org, and then used the normal rewrite command (with no external rewrite) and it *did* work (although I didn't bother to try to fix the missing images due to the change in URL). It obviously accessed it as www.dreamtime.org/whatever rather than rewriting it to http://photos.dreamtime.org/

I've tried to juggle various things in the rewrite rules but to no avail. I am surprised if I am the first to want to split out to a separate G2 site whilst having G1 -> G2 rewrites working :|

Any suggestions on where to go from here?
Any further information required?

Thanks in advance

Ivan

NOTE:
* G1 webserver is currently on a physically different machine from the G2 webserver.
* I have not bothered to get G1 working on the new machine as I only need it for the migration.


Much of the below is, I believe, irrelevant to the problem, but included for completeness:

G2 URL (optional): http://photos.dreamtime.org/photos/
G2 version: 2.1.2 core 1.1.0.2 (PHP 4.4.2-1.1)
G2 PHP memory limit: 16M
G1 URL (optional): http://www.dreamtime.org/photos/
G1 version: 1.5.4-debian1
G1 character set: en-GB (locale alias en_GB.utf8)
G1 PHP memory limit: 100M
--
PHP version (e.g. 4.3.11): 4.4.2-1.1
PHPInfo Link (see FAQ): http://photos.dreamtime.org/photos/phpinfo.php
PHP version = 4.4.2-1.1
Webserver = Apache/2.0.55 (Ubuntu) PHP/4.4.2-1.1
Database = postgres7 , lock.system=flock
Toolkits = ArchiveUpload, Dcraw, Exif, Ffmpeg, Getid3, ImageMagick, NetPBM, SquareThumb, Thumbnail, Gd
Operating system = Linux
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9 Mnenhy/0.7.4.0

 
ivan_bev

Joined: 2006-04-10
Posts: 14
Posted: Sat, 2007-01-20 16:23

To be more explicit, I put the above rewrite stuff in a "location" block in apache's virtual-host config, a la:

<Location ~ "/photos">
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Rewritecond %{REQUEST_FILENAME} !gallery_remote2.php
    RewriteRule (.*)$ http://photos.dreamtime.org/photos/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]
  </IfModule>
</Location>

which gave the above issues. I believe this is still valid (as I believe putting the same entry in a directory block would do the same thing.

To resolve the problem, I put it in the virtual-server context (ie outside a "location" or "directory" block) and the below worked for what I wanted
( http://www.dreamtime.org/photos/GALLERY1INSTALL -> http://photos.dreamtime.org/photos/GALLERY2INSTALL )

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  Rewritecond %{REQUEST_FILENAME} !gallery_remote2.php
  RewriteRule ^/photos/(.*)$ http://photos.dreamtime.org/photos/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]
</IfModule>

May I suggest that this gets documented somewhere? I can't imagine I'm the only person that will want to do a G1 -> G2 migration in combination with a server move.