I want to rename an album (the part in the url, not just the text) but don't want all my old links to break...

WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sat, 2012-04-07 22:00

I have an album that started out as mostly Ink, but I put paintings in there as well (I had very few paintings at the time)... since then it's become 99% paintings and it looks ridiculous for the url to say "Ink" instead of "Paintings"... so I'd like to change it, but if I do, all my old links to the gallery will break. Is there a mod_rewrite trick I can do so that links that point to the "Ink" folder (I know it's not REALLY a folder) will redirect to the "Paintings" folder?

Here is the actual album in question: http://gallery2.opalcat.com/gallery2/v/Art/Ink/

I'd like it to be http://gallery2.opalcat.com/gallery2/v/Art/Paintings/


Gallery version (not just "2"): 2.3.1 core 1.3.0.1
PHP version (e.g. 5.1.6):5.2.17 cgi-fcgi
PHPInfo Link (see FAQ): http://gallery2.opalcat.com/gallery2/phpinfo.php
Webserver (e.g. Apache 1.3.33): Apache
Database (e.g. MySql 5.0.32):mysqli 5.1.62-community-log, lock.system=flock
Activated toolkits (e.g. NetPbm, GD): ArchiveUpload, Exif, Getid3, ImageMagick, LinkItemToolkit, NetPBM, Thumbnail, Gd
Operating system (e.g. Linux):Linux host180.hostmonster.com 2.6.32-46.1.BHsmp #1 SMP Tue Sep 6 12:18:02 MDT 2011 x86_64
Browser (e.g. Firefox 2.0): Google Chrome 17.0.963.79 m

--
WebKat, Gallery2 holdover extraordinaire.

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sat, 2012-04-07 22:32

Apache:
RewriteCond %{THE_REQUEST} /gallery2/v/Art/Ink(/?)
RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
RewriteRule . /gallery2/v/Art/Paintings/ [QSA,L]

Nginx:
rewrite ^/gallery2/v/Art/Ink(/?) /gallery2/v/Art/Paintings/ last;

--
dakanji.com

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sun, 2012-04-08 01:25

Ok where would I put that in this .htaccess file? And then would I go ahead and rename the folder?

# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /gallery2/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   -   [L]

    RewriteCond %{THE_REQUEST} /gallery2/d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/([^?]+)\.davmount(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=webdav.DownloadDavMount&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/w(/[^?]*)?(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_controller=webdav.WebDav&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_path=%1   [QSA,L]
</IfModule>

# END Url Rewrite section

Thanks for your help!

--
WebKat, Gallery2 holdover extraordinaire.

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sun, 2012-04-08 04:19
# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /gallery2/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   -   [L]

    RewriteCond %{THE_REQUEST} /gallery2/d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/([^?]+)\.davmount(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=webdav.DownloadDavMount&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/w(/[^?]*)?(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_controller=webdav.WebDav&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/Art/Ink(/?)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule . /gallery2/v/Art/Paintings/ [QSA]
    RewriteCond %{THE_REQUEST} /gallery2/v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_path=%1   [QSA,L]
</IfModule>

# END Url Rewrite section

Notes:

1. The line has been ended with ([QSA] and not [QSA,L] which should be more efficient here. Test this first (I don't use Apache so I can't). If it doesn't work, change to [QSA,L]
2. If you reset the rewrite module, the htaccess will be over written. So back it up ... "htaccess.bak" is a good name

--
dakanji.com

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sun, 2012-04-08 15:17

I tried it the first way, and got this:

Error
Item not found.

Back to the Gallery

Error Detail -
Error (ERROR_MISSING_OBJECT) : Parent 2644 path Ink
in modules/core/classes/helpers/GalleryFileSystemEntityHelper_simple.class at line 98 (GalleryCoreApi::error)
in modules/core/classes/GalleryCoreApi.class at line 1952 (GalleryFileSystemEntityHelper_simple::fetchChildIdByPathComponent)
in modules/core/classes/helpers/GalleryFileSystemEntityHelper_simple.class at line 53 (GalleryCoreApi::fetchChildIdByPathComponent)
in modules/core/classes/GalleryCoreApi.class at line 1901 (GalleryFileSystemEntityHelper_simple::fetchItemIdByPath)
in modules/rewrite/classes/RewriteSimpleHelper.class at line 45 (GalleryCoreApi::fetchItemIdByPath)
in ??? at line 0 (RewriteSimpleHelper::loadItemIdFromPath)
in modules/rewrite/classes/RewriteUrlGenerator.class at line 103
in modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class at line 56 (RewriteUrlGenerator::_onLoad)
in init.inc at line 170 (ModRewriteUrlGenerator::initNavigation)
in main.php at line 197
in main.php at line 104
in main.php at line 88
System Information
Gallery version	 2.3.1
PHP version	 5.2.17 cgi-fcgi
Webserver	 Apache
Database	 mysql 5.1.61-community-log
Toolkits	 ImageMagick, Thumbnail, NetPBM, Gd
Operating system	 Linux host180.hostmonster.com 2.6.32-46.1.BHsmp #1 SMP Tue Sep 6 12:18:02 MDT 2011 x86_64
Browser	 Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19

Then I changed it to [QSA,L] and now it gives a 500 server error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator,  and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

--
WebKat, Gallery2 holdover extraordinaire.

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sun, 2012-04-08 15:18

(I changed it back and re-renamed it back to Ink for now just so it's working.)

--
WebKat, Gallery2 holdover extraordinaire.

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sun, 2012-04-08 16:19

One more thing, since you seem to know your .htaccess stuff... perhaps you can help me with this other thing: http://gallery.menalto.com/node/105969 --I upgraded from G1>G2 several years ago, but didn't complete the mapping process so that my old links would work and redirect to the new install. Now, I checked the database and the migration map info is there... but I don't know what to put in the .htaccess file to make it work. Any ideas? The specific info is in that other thread.

--
WebKat, Gallery2 holdover extraordinaire.

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sun, 2012-04-08 16:36

Try this instead in the same location

RewriteCond %{THE_REQUEST} /gallery2/v/Art/Ink/
RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_path=Art/Paintings [QSA,L]

I'll have a look at the other post.

--
dakanji.com

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Sun, 2012-04-08 16:44

That worked! :D Thank you so much!

--
WebKat, Gallery2 holdover extraordinaire.