Apache::LangURI - Rewrite Accept-Language headers from URI path and back
# httpd.conf PerlSetVar DefaultLanguage en # for redirecting the url based on the top language # in the inbound header PerlSetVar ForceLanguage on PerlAddVar IgnorePathRegex ^/foo # and the opposite: PerlAddVar IgnorePathRegex !^/foo/bar PerlTransHandler Apache::LangURI
Apache::LangURI will attempt to match the first segment of the path of an http URL to an RFC3066 <major>-<minor> language code. It will also optionally prepend the "best" language code to the path, should it not already be there. Language tags are normalized to a lower case major with an upper case minor and a hyphen in between.
This defines the default language that will be added at a diminished quality value after the language found in the URI path, should its major part not match. This is to ensure that a suitable variant will always be returned when content negotiation occurs. Defaults to 'en' if omitted.
Setting this variable to a positive (1|true|on|yes) value will cause the server to redirect the user to a path beginning with the language code of the highest quality value found in the Accept-Language header. This occurs only when the URI path does not begin with an RFC3066 language code. This directive can be omitted if this behavior is not desired.
Passing a regular expression (optionally prefixed by ! to denote negation) will limit the effect of this handler to simulate <Location> blocks on a transhandler.
if set to a positive (1|true|on|yes) value, the server will return 301 Moved rather than 302 Found on a successful redirection.
Only currently does ISO639 language majors and ISO3166 country minors. No support for constructs like "no-sami" or "x-jawa".
RFC3066 includes rules for pairings of ISO639-1/2 and ISO3166 two-character and three-character denominations. This module does not enforce those rules.
The DefaultLanguage variable will eventually be phased out to use Apache::Module to derive the value from mod_mime as soon as this author manages to get it to compile.
Forms that refer to absolute URL paths may no longer function due to the redirection process, as the POST payload will be interrupted.
ISO 639 ISO 3166
Dorian Taylor, <firstname.lastname@example.org>
Copyright 2003 by Dorian Taylor