#!/usr/bin/perl # # This script redirects people who want an unsupported language to a default # language, overriding Apache's default behavior of offering people a slightly # confusing list of choices (which is in English anyway, go figure...). # # To use it, put the following line in your .htaccess file: # # ErrorDocument 406 /cgi-bin/language-error.pl/?en # # Note the last / - it is important! This example redirects people to files # ending in ".en", which is what I use for English. Feel free to use any # other extension or any other language you like... # # Author: Bjarni R. Einarsson, http://bre.klaki.net/ # $Id: language-error.pl,v 1.5 2000/04/06 22:14:18 bre Exp $ # This script is in the public domain. # my $def = $ENV{"QUERY_STRING"}; my $url = $ENV{"REDIRECT_URL"}; my $root = $ENV{"PATH_TRANSLATED"}; $def =~ s/[^a-zA-Z]//g; exit 1 unless ($def); exit 1 unless ($url); exit 1 unless (-d $root); if (-e "$root/$url.$def") { $url .= ".". $def; } elsif (-e "$root/$url" ."index.$def.html") { $url .= "index.$def.html"; } elsif (-e "$root/$url" ."index.html.$def") { $url .= "index.html.$def"; } elsif (-e "$root/$url" ."index.$def.shtml") { $url .= "index.$def.shtml"; } elsif (-e "$root/$url" ."index.shtml.$def") { $url .= "index.shtml.$def"; } else { exit 1; # No file found, fall back to default Apache error handler! } print "Location: $url Status: 301 Moved Permanently Content-Type: text/html 301 Moved Permanently

Moved Permanently

The document has moved here.

";