+++ /dev/null
-#!/usr/bin/perl
-
-my $lang = "en";
-
-# Set language to german, else use english site
-if ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /^de(.*)/) {
- $lang = "de";
-}
-
-print "Status: 302 Moved\n";
-print "Pragma: no-cache\n";
-
-if ($ENV{'SERVER_NAME'} eq "source.ipfire.org") {
- print "Location: /$lang/source.shtml\n";
-} elsif ($ENV{'SERVER_NAME'} eq "tracker.ipfire.org") {
- print "Location: /$lang/tracker.shtml\n";
-} else {
- print "Location: http://www.ipfire.org/$lang/index.shtml\n";
-}
-
-# End http header...
-print "\n";
--- /dev/null
+#!/usr/bin/python
+
+import os
+import re
+
+sites = (
+ ("ipfire.org", ("www.ipfire.org", None)),
+ ("www.ipfire.org", (None, "index.shtml")),
+ ("source.ipfire.org", (None, "source.shtml")),
+ ("tracker.ipfire.org", (None, "tracker.shtml")),
+ ("download.ipfire.org", (None, "download.shtml")),
+ )
+
+# Check language...
+if re.search(re.compile("^de(.*)"), os.environ["HTTP_ACCEPT_LANGUAGE"]):
+ language = "de"
+else:
+ language = "en"
+
+print "Status: 302 Moved"
+print "Pragma: no-cache"
+
+location = ""
+
+for (servername, destination) in sites:
+ if servername == os.environ["SERVER_NAME"]:
+ if destination[0]:
+ location = "http://%s" % destination[0]
+ if destination[1]:
+ location += "/%s/%s" % (language, destination[1])
+ break
+
+print "Location: %s" % location
+print # End the header