Redirecting old Gallery 1 URLs to Gallery 3

Here's how to get your old Gallery 1 URLs to redirect through the Gallery 2 URL mapper, through the Gallery 3 URL mapper into current Gallery 3 URLs

Redirect Sequence

This will result in this sequence of redirects :

Apache httpd config

Some assumptions :

<VirtualHost *:80>
    DocumentRoot /path/to/g2site
    ServerName g2.example.com

    RewriteEngine On
    # This rewrites requests from people just typing in your g2 site root URL to your g3 site
    # http://g2.example.com/ -> http://g3.example.com/
    RewriteRule ^/$ http://g3.example.com/   [L,R=301]

    <Directory /path/to/g1site/albums>
        # This code originates from the Gallery 2 "Migrate" plugin/module
        # http://codex.galleryproject.org/Gallery2:Modules:migrate
        # The only changes made here are to add a "L" directive to the RewriteRule
        # To force mod_rewrite to stop processing if it gets a match
        # and to add a "R=301" directive to indicate this is a permanent redirect
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !gallery_remote2.php
            RewriteRule (.*)$ /gallery/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA,L,R=301]
        </IfModule>
    </Directory>

    <Directory /path/to/g2site/gallery>
        # This code takes incoming Gallery 2 URLs and passes them to the Gallery 3 URL mapper
        # (convert g2 urls to g3 urls). Here we ignore requests that contain 
        # "g2_controller=migrate.Redirect" because these need to be processed by the 
        # Gallery 2 URL mapper (convert g1 urls to g2 urls)
        <IfModule mod_rewrite.c>
            Options +FollowSymLinks
            RewriteEngine On
            RewriteBase /gallery/
            RewriteCond %{QUERY_STRING} !^g2_controller=migrate\.Redirect
            RewriteRule ^(.*)$ http://g3.example.com/g2/map?path=$1   [QSA,L,R=301]
        </IfModule>
    </Directory>
</VirtualHost>

Original Apache httpd config snippets

Original unmodified Gallery 2 Migrate Module apache config
This config was put in an .htaccess file in your Gallery 1 "albums" directory

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

Original unmodified Gallery 3 g2_import apache config
This config was put in gallery2/.htaccess

<IfModule mod_rewrite.c>
      Options +FollowSymLinks
      RewriteEngine On
      RewriteBase /gallery/
      RewriteRule ^(.*)$ /g2/map?path=$1   [QSA,L,R=301]
    </IfModule>

Prior art

Here is a thread with people trying to create this but without luck : http://galleryproject.org/node/103597

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.