Gallery2:Modules:permalinks - Gallery Codex
Personal tools

Gallery2:Modules:permalinks

From Gallery Codex

Permalinks Module

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

Description

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:

http://www.example.com/gallery2/main.php?g2_itemId=5471

Example of a normal short URL:

http://www.example.com/gallery2/v/Countries/Switzerland/Zurich.html

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:

http://www.example.com/gallery2/f/Zurich

Usage

  • 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:

http://www.example.com/gallery2/f/myitem

Example using using the "PHP pathinfo" option:

http://www.example.com/gallery2/main.php/f/myitem

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.

Notes

  • 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).