#!/usr/local/bin/perl

################################################
#  redir version 0.1  -- a cache module for WN
#  Usage: (in index file)
#
#  Cache-module=redir URL    (redirects everything to URL)
#
#  or
#
#  Cache-module=redir URL/    (redirects foo to URL/foo)
#
################################################


# First get URL (listed in Cache-module line of index file)
$url = shift;

# Next get the name of file requested from this directory.  It has
# been place in the environmental variable WN_KEY by the server.
$file = $ENV{WN_KEY};

# If the URL ends in '/' append the file name to it
$url = $url.$file if $url =~ m|/$|;

# Return line in index.cache format, e.g. "file=foo&redirect=http://host/bar"
print "file=$file&redirect=$url\n";

