Gallery2:Modules:permalinks - Gallery Codex
Personal tools


From Gallery Codex

Permalinks Module

Use permanent links (URLs) as addresses for your albums and items.


One of the nice and bad aspects of G1 was that the namespace of albums was flat: you couldn't have two albums named the same within the same gallery. G2, with its truly hierarchical albums, fixes this, at the expense of those nice short descriptive URLs: URLs in G2 are either very long or meaningless (with the rewrite module).

Example of an original URL:

Example of a normal short URL:

With Permalinks, you can have the best of both worlds: short descriptive URLs for some of your albums (and even any other item) which have the added benefit of not changing if you move an album into a different parent album.

Example of a permalink URL:


  • Install and activate URL Rewrite rule
  • Install and activate the permalinks module
  • Goto Site admin -> URL rewrite, Tab Rules, Section Permalinks an activate it.
  • Add/delete permalinks for items in General tab of "Edit Item" / "Edit Album" / "Edit Photo."
  • Optional: Turn on auto-permalink creation and delete existing permalinks in Site Admin -> Permalinks.

After activating the module, you need to enable the corresponding URL Rewrite (the URL Rewrite module also needs to be enabled, using either "Apache mod_rewrite" or "PHP pathinfo"). Once that's done, you can define a Permalink for any item in that item's edit interface. You can then access the item using a short URL that doesn't depend on the item's location. The URL is build from the gallery-base-URI, a fix path (default "f/") defined in Site-Admin section Permalinks (see above) and the Permalink defined for the item ("myitem" in the example).

Example using the "Apache mod_rewrite" option:

Example using using the "PHP pathinfo" option:

Some more explanation:

  • Check directory /etc/apache2/mods-enabled/ for the mod_rewrite module to be loaded. This is preferred over php_pathinfo.
  • Log in Gallery2 with an administrator account and click Site Admin, then Plugins, and check for a Green Check at plugin Permalinks. If you see a Red Check instead, click this module's name and follow instructions.
  • The instructions suggest to create a .htaccess file that's writable by the web server in your Gallery2 directory.
  • After activation, Gallery2 will write an impressive Apache URL Rewrite section to this .htaccess file.
  • Either set a Permalink to an individual item or album by clicking on Edit Item or Edit Album, or enable Auto-Permalinks in Site Admin -> Permalinks.
  • Check the Apache error.log on any problem. If it shows ".htaccess: Option FollowSymlinks not allowed here" try removing "Options +FollowSymlinks" from the .htaccess file in your Gallery2 directory.


  • If also using the Hidden module, it is not possible to use a permalink to unhide a hidden item.
  • The Permalinks plugin does not change or affect navigation methods inside Gallery. So if you publish your permalink some place you will in effect have at least 2 URLs to your items (photos, movies, etc).