Apache::AliasList

The idea behind Apache::AliasList is to provide an easy and maintainable way to map 'simple' URLs to the more complex URLs used by content management systems. For example, instead of linking to http://perl.jonallen.info/bin/view/Main/PerlModules I can use http://perl.jonallen.info/modules, which looks better in print and is easier to convey verbally.

The module is installed as a translation handler in a mod_perl enabled Apache web server. The list of URIs to remap is stored in a plain text file (alias.list). Each line in this file corresponds to a single alias, with the format /old_uri [whitespace] /new_uri. All local URIs must start with a forward slash character. Trailing slashes in the old_uri will be ignored (so http://your.site/alias and http://your.site/alias/ are both valid), but are preserved in the new_uri. The new_uri can also be a fully qualified URL (http://host.tld/path/to/page.html). If a line starts with a '#' character, it will be treated as a comment and ignored. Data in the alias.list file may be changed at any time without updating the Apache configuration or rebooting the server.

Apache configuration:

PerlTransHandler Apache::AliasList
PerlSetVar AliasList /full/path/to/alias.list

Example alias.list file:

# Comments can be included
/talks       /bin/view/Main/PerlTalks
/bookreviews /bin/view/Main/BookReviews
/code        /bin/view/Main/CodeSnippets
/modules     /bin/view/Main/PerlModules
#/old        /this/will/not/be/used
/www         http://www.jonallen.info
/photos      http://photoalbum.jonallen.info

Download