.htaccess connundrum--Please Help!

creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 17:14

I have recently moved from G2 to G3 and for the most part, I like the new version. I have a bit of a situation, though and wonder if someone can help. I have my gallery installed in a subdomain of my webserver. I know the migration instructions had a bit of code to place in the .htaccess file of the G2 installation to redirect to G3. It kind of bothers me, though, to have to leave my subdomain pointed at an old folder that does nothing but redirect to a new folder. I'd much rather point my subdomain at the new folder with the G3 install. The only difference between the two is in the format of the Pretty URLs that are generated.
My G2 install uses domain.com/albums/PrettyPathToAlbum and my G3 install uses domain.com/PrettyPathToAlbum.

I'd love to just include a mod_rewrite directive in my .htaccess file of G3 to translate between the two so that all the old links still work. But when I do a straight redirect, it breaks the "Add new Album" function of G3. (I'm assuming G3 uses the domain.com/albums format in the add code.) Is there a way to know when it's an add from G3 and when it's an old link so that a rewrite condition could be used? I'm only slightly versed in mod_rewrite and extremely new to G3 so you may have to dumb it down for me.

Any help someone can give would be greatly appreciated!!

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-02-26 18:09

I missed half of that. What's in the subdomain?

What is:
(1) The url for an album in the old gallery
(2) The url for that same album in the new gallery

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 18:12

ok. Thanks for trying to help me!

The url G2 Album: subdomain.domain.com/albums/AlbumName
The url G3 Album: subdomain.domain.com/AlbumName

I know you said leave off other stuff, but I thought I'd post the mod_rewrite directive that I've already tried (It redirects just dandy, but it broke the "add album" capability in G3). I copied the RewriteCond statements from the existing file hoping they'd help and put this as a separate command in the file (leaving the original rewrite statements alone).

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^albums/(.*)$ $1 [QSA,R,L]
</IfModule>

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-02-26 18:24

Are you using any other rewrites in the htaccess file? If so, can you paste a copy of the whole thing?

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 18:29

The only other rewrite is just the default that was generated with the G3 installation. So right below the block I pasted above is the following:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^index.php/(.*) $1 [QSA,R,L]

</IfModule>

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-02-26 18:44

Okay, first, try just replacing your block with: [deleted]

Let me know what happens.

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 18:42

well...that didn't work. It doesn't redirect and any album related functions are broken (edit, add, etc.)

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-02-26 18:50

Just retested. Now I see the problem. Not sure that can be done easily. I'd have to sort through the Gallery3 code to see how it uses the albums directory and then write a rule that doesn't apply in those cases.

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 18:49

That didn't work either. I when I tested the redirect, I got an error page and the resulting URL looked like this:

http://sub.domain.com/$1AlbumName?kohana_uri=albums/AlbumName

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Sat, 2011-02-26 19:05

tempg,
I really appreciate your help on this. I know it's not a huge deal, but it would be nice if old links floating around weren't broken. However, my site doesn't get too much traffic, so the impact will be fairly small.

I'm going to be afk for a while, so if you have any other suggestions, my response may not be quite as fast as it has been. ;)

Thanks again! Your time has been greatly appreciated!

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2011-02-27 14:30

If you don't have much traffic (and, therefore, don't have many base-level galleries), it'll be much easier to just create an htaccess file for your site specifically (based on applying only to your galleries) instead of trying to work around Gallery3's needs (that could presumably change in the future).

If you're willing to post a link to your site (or pm it to me, I guess), I'll work something up.
If not, you can try to play around with it; shouldn't be too complicated.

 
creationsings

Joined: 2008-02-07
Posts: 57
Posted: Mon, 2011-02-28 14:49

I'm don't think I understand what you mean: I was simply trying to prevent old links that are still floating around the web from being broken. But I'm willing to try anything. My gallery is currently at gallery [dot] creationsings [dot] net. (Forgive the paranoia -- don't know why I have it!) :-D
It only has my photos and artwork on it. I have noticed there are a lot of file-not-found errors in the logs, though, in just the 4 days since I've moved over to G3. The overwhelming majority are from URLs that would have worked when it was G2.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2011-02-28 15:12

That is the Gallery3 version; I was looking for the Gallery2 version. But, if they have the same structure, just add this to the htaccess file:

Redirect 301 /albums/Photography http://gallery.creationsings.net/Photography
Redirect 301 /albums/Art http://gallery.creationsings.net/Art

Let me know if that does the trick.