Clean Photo Album permalinks with Piwigo

I am playing for some time now with Piwigo to replace my Menalto Gallery3 online photo gallery. Key reason to look at another solution is that after the move from Gallery 2 to 3 the project (which took ages as it was a major overhaul of the code), the projects seems to have stalled.

So far I really like Piwigo as it has everything I need including iPhoto integration and a (simple) iPhone app. LDAP support is available through a plugin that is basic but suffices for my need. However, one of the key gaps for me was that it did not have any way to generate nice and simple URLs to albums that you can share easily (verbally). Although it was possible to define permalinks for an album, the URL remained ugly in my opinion.
Today I hacked a small patch together for the Piwigo 2.6 codebase that changes the URLs for photo albums to something like:

http://photo.mydomain.tld/albumname

which is exactly the way it worked for me fine (like I had with Gallery3). This only works for albums with a permalink defined, default album URL will retain the /category/<albumid> format, which is fine for my situation.

Steps to obtain more clean album URLs are:

  1. Apply this patch: piwigo-url-patch
  2. Add the following mod_rewrite rewriting rules to your Apache configuration
    RewriteRule ^/category/       /index.php/%{REQUEST_URI}               [L]
    RewriteRule ^/[^.]+$          /index.php/category/%{REQUEST_URI}      [L]

Again, in my setup this worked, I am still testing this so any feedback to improve is welcome. I did notice that occasionally the patch results in a / too many in URLs generated by piwigo, but that is silently ignored and does not affect the functionality.

To actually use the patch, define a permalink under [Administration] –> [Albums] –> [Manage] on the [Permalinks] tab.

One Reply to “Clean Photo Album permalinks with Piwigo”

  1. Hello. I have switched from gallery2 (2.3.2) to piwigo (2.7.4) and I’m trying to make the links more friendly. I stumble upon your article. Unfortunately something not working for me.

    The site is installed in http://sitename.com/g/piwigo

    I have the following “.htaccess” :
    AcceptPathInfo On
    Options +MultiViews
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /g/piwigo/
    RewriteRule ^/category/ /index.php/%{REQUEST_URI} [L]
    RewriteRule ^/[^.]+$ /index.php/category/%{REQUEST_URI} [L]

    my Piwigo config “local/config/config.inc.php”
    $conf[‘gallery_url’] = null;
    $conf[‘question_mark_in_urls’] = false;
    $conf[‘php_extension_in_urls’] = true;
    $conf[‘category_url_style’] = ‘id-name’;
    $conf[‘picture_url_style’] = ‘file’;
    $conf[‘tag_url_style’] = ‘tag’;

    I have applied your patch manually to “functions_url.inc.php” and checked 2 times.

    I had already permalinks defined for all albums in the gallery.

    When I access gallery root http://sitename.com/g/piwigo is ok, but when i’m clicking on an album it goes me to the link: http://sitename.com/albumname , and

    the following error appear: “Not Found . The requested URL /albumname was not found on this server.”

    Any idea what is the problem?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.