rewrite g1 long urls

reconone

Joined: 2006-06-02
Posts: 2
Posted: Fri, 2006-06-02 01:35

i recently performed a g1->g2 migration. i renamed the g1 directory and installed g2 where g1 used to be.

everything went smoothly with one exception. long url g1 links do not redirect. it's my understanding that the built-in g1->g2 mapping in g2 works only for g1 short urls. i've been blogging for over a year and linking to images using g1 long url's. rather than search back through hundreds of entries to find all of these broken links, i'm wondering if there is a way to redirect in the g2 .htaccess file.

this works to redirect the albums:

Quote:
RewriteCond %{THE_REQUEST} \ /gallery/view_photo.php\?set_albumName=([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !main\.php
RewriteRule . /gallery/main.php?g2_view=core.ShowItem&g2_path=%1 [QSA,L]

but i'm looking for something to redirect individual image pages (for example: /gallery/view_photo.php?set_albumName=20060311&id=aac).

any help would be greatly appreciated.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-06-02 05:05

make a similar rule that parses the set_albumName and id values and rewrites with g2_path=%1/%2

 
reconone

Joined: 2006-06-02
Posts: 2
Posted: Fri, 2006-06-02 06:10

thanks to your comment, mindless, i figured this out.

here's what i needed... i'm sure the regex could be simplified a bit, but this works for me given that all of my images are named aaa-zzz:

Quote:
RewriteCond %{THE_REQUEST} \ /gallery/view_photo.php\?set_albumName=([0-9]*[0-9])&id=([a-z][a-z][a-z])
RewriteCond %{REQUEST_FILENAME} !main\.php
RewriteRule . /gallery/main.php?g2_view=core.ShowItem&g2_path=%1/%2.jpg.html [QSA,L]

RewriteCond %{THE_REQUEST} \ /gallery/view_photo.php\?set_albumName=([0-9]*[0-9])
RewriteCond %{REQUEST_FILENAME} !main\.php
RewriteRule . /gallery/main.php?g2_view=core.ShowItem&g2_path=%1 [QSA,L]

note that i did need to add .jpg.html for the redirect to work properly... %1/%2 didn't do it by itself. thanks a ton, mindless... really appreciate the help.