NAME
Apache::AliasList - Apache translation handler to process lists of aliases
SYNOPSIS
In httpd.conf:
PerlTransHandler Apache::AliasList
PerlSetVar AliasList /path/to/alias.list
In alias.list:
# Comment lines ignored
/alias /full/uri/spec.html
If http://domain/alias is requested, the document at http://domain/full/uri/spec.html will be delivered.
DESCRIPTION
When using a content management system, it is common for URIs to become quite long and complex. In many cases it is therefore desirable to provide a shorter, more descriptive URI (e.g. to convey verbally or in print).
Apache provides an Alias
directive which can be used to make these translations in the httpd.conf configuration file. This approach however has the disadvantage that a server restart is required for any changes to take effect. Apache::AliasList removes this requirement by moving the alias definitions into a separate file which can be updated without restarting the server.
When an incoming request matches one of the listed aliases, an internal redirect is performed - this keeps the original URI in the location bar of the user's browser.
If the incoming request matches the target of any defined aliases, Apache::AliasList will issue an HTTP status 302 response to redirect the client to the source URI of the alias. This has the effect of changing the URI shown in the client browser's location bar
Configuration
Create an alias.list file:
# Comments start with '#'
/old_uri /location/to/be/redirected/to
/test http://can.redirect.to/external/sites
Add the following directives to httpd.conf:
PerlTransHandler Apache::AliasList
PerlSetVar AliasList /full/path/to/alias.list
Example
There is an alias between the pages http://perl.jonallen.info/modules and http://perl.jonallen.info/bin/view/Main/PerlModules.
Accessing the URI http://perl.jonallen.info/modules will trigger the internal redirect. The address shown in the browser does not change, but the content returned is from the longer URI.
Requesting the page http://perl.jonallen.info/bin/view/Main/PerlModules causes the external redirect to be issued, taking the client to http://perl.jonallen.info/modules. This URI will then be processed as described above.
TODO
Extend the reverse map feature to act as a content filter, substituting URI links with their aliases in the returned HTML document.
AUTHOR
Written by Jon Allen (JJ) <jj@jonallen.info>
COPYRIGHT
Copyright (C) 2004 Jon Allen
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
http://perl.jonallen.info