Redirecting G1 URLs to G2

ghowley
ghowley's picture

Joined: 2008-04-08
Posts: 4
Posted: Tue, 2008-04-08 22:48

I just converted up from Gallery 1 to Gallery 2. The conversion went pretty well, and moved all my files over, and Gallery2 works great. My problem now is that I'd like references to the old URLs to automatically redirect to their Gallery2 counterparts.

I've added the new .htaccess files to my gallery folder and the albums folder inside it, I've got the migration module active, and I've got URL Rewrite's migration function set to active.

Here's where it gets weird. I've posted thumbnails elsewhere that linked to the actual gallery1 page with the image. The thumbnails now appear, and if you right click and choose "view image", you get the Gallery2 image. (I've deleted the gallery1 images) However, when you click that image to go to the URL that used to be the gallery1 page, you reach a blank page. Not a 404 error. A blank page.

I'm not sure why the redirection works only partially, but I'd welcome any tips anyone can provide.

Old Gallery1 URL: http://greghowley.com/gallery
Gallery2 URL: http://greghowley.com/gallery2
Images linked from: http://liahowley.com/

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Tue, 2008-05-13 19:53

You might need to hand-edit your .htaccess file -- did you not have mod_rewrite set up before?

 
ghowley
ghowley's picture

Joined: 2008-04-08
Posts: 4
Posted: Tue, 2008-05-13 20:00

I actually was using mod_rewrite for other things, and I know basics about htaccess, but not enough to fix this problem.

At this point, I've pretty much accepted that I'll have to live with this problem, but if anyone posts suggestions, I'll certainly give them a shot. Thanks.

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Tue, 2008-05-13 20:27

Let's see if this works. Put this in a file called "view_photo.php" in your /gallery directory. You might have to then copy or link it into place for view_album (or whatever it was called).

<?php
/*
 * Set this to the base directory of your gallery2.  Theoretically, I have done
 * that for you.
 */
$base_url = 'http://greghowley.com/gallery2/main.php';
$migration_path = '?g2_controller=migrate.Redirect&g2_path=';
$album_name = '';
if (!empty($_GET['set_albumName'])) {
    $album_name = $_GET['set_albumName'];
}
$id = '';
if (!empty($_GET['id'])) {
    $id = $_GET['id'];
}
if ($album_name && $id) {
    /* We have an album name and a filename */
    header('Location: ' . $base_url . $migration_path . $album_name . '/' . $id);
    exit;
}
if ($album_name) {
    /* We just have an album name */
    header('Location: ' . $base_url . $migration_path . $album_name);
    exit;
}
header('Location: ' . $base_url);
?>
 
ghowley
ghowley's picture

Joined: 2008-04-08
Posts: 4
Posted: Thu, 2008-05-22 22:31

Excellent! Thanks a lot.

I put it in place, and it looks like the album_name and filename path works, but the album name only does not.

Still, it's a start, and I feel comfortable tweaking the code from here, as I can see what you're doing. You've given me the start I need. Now I just need to put aside 15 minutes to play with the code...

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Thu, 2008-05-22 22:43

I think that you might need to copy it to view_album.php (or whatever the old file name was) or put another line in your .htaccess to rewrite for you.

 
ghowley
ghowley's picture

Joined: 2008-04-08
Posts: 4
Posted: Thu, 2008-05-22 22:57

That did it. I'm 100% back in business. Thanks again.
It was a low priority for me - when you've been spending all day looking at code, you tend not to be overly enthusiastic about doing it in your free time, but that was quick and easy.

Thank you sir - you are a gentleman and a scholar.

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Mon, 2008-06-02 05:17

Ha! No one has said that since I was in the ninth grade!