Apache-AliasList
view release on metacpan or search on metacpan
AliasList.pm view on Meta::CPAN
#! /usr/bin/perl
=head1 NAME
Apache::AliasList - Apache translation handler to process lists of aliases
=head1 SYNOPSIS
In F<httpd.conf>:
PerlTransHandler Apache::AliasList
PerlSetVar AliasList /path/to/alias.list
In F<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.
=head1 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 C<Alias> directive which can be used to make these
translations in the F<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
=head2 Configuration
Create an F<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 F<httpd.conf>:
PerlTransHandler Apache::AliasList
PerlSetVar AliasList /full/path/to/alias.list
=head2 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.
=head1 TODO
Extend the reverse map feature to act as a content filter, substituting
URI links with their aliases in the returned HTML document.
=head1 AUTHOR
Written by Jon Allen (JJ) <jj@jonallen.info>
=head1 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.
=head1 SEE ALSO
http://perl.jonallen.info
=cut
( run in 1.695 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )