aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php16
-rw-r--r--langs.inc.php15
2 files changed, 28 insertions, 3 deletions
diff --git a/index.php b/index.php
index 2d86636d6..750ce878d 100644
--- a/index.php
+++ b/index.php
@@ -7,17 +7,27 @@ require_once 'langs.inc.php';
// NOTE, this should go to the main controller in the next platform
// (catching all requests)
-$domain = 'mageia.org';
+$domain = 'mageia.org';
$www_domain = 'www.' . $domain;
+
if (G_VHOST == $domain) {
+ // rewrite "//mageia.org/" to "//www.mageia.org/"
header ('HTTP/1.1 301 Moved Permanently');
header(sprintf('Location: http://%s%s', $www_domain, $_SERVER['REQUEST_URI']));
die;
-} elseif (G_VHOST != $www_domain) {
+}
+elseif (isset($_GET['fromtld'])) {
+ // rewrite "//mageia.org/?fromtld=it" to "//www.mageia.org/it/"
+ tld_redirect($_GET['fromtld'], $domains_lang, $www_domain);
+}
+elseif (G_VHOST != $www_domain) {
+ // rewrite "//mageia.it/" to "//www.mageia.org/it/"
domain_redirect($_SERVER['SERVER_NAME'], $domains_lang, $www_domain);
}
-if (isset($_GET['langs'])) { die(show_langs($langs)); }
+if (isset($_GET['langs'])) {
+ die(show_langs($langs));
+}
if (isset($_GET['flang']))
{
diff --git a/langs.inc.php b/langs.inc.php
index 7409f5b9d..db65777de 100644
--- a/langs.inc.php
+++ b/langs.inc.php
@@ -48,6 +48,21 @@ $domains_lang = array(
* Redirect to a localized path, depending on incoming TLD.
* Only manages redirections to main home path.
*
+ * @param string $tld
+ * @param array $domains_lang
+ * @param string $vhost
+ *
+ * @return void
+*/
+function tld_redirect($tld, $domains_lang, $vhost)
+{
+ domain_redirect('mageia.' . $tld, $domains_lang, $vhost);
+}
+
+/**
+ * Redirect to a localized path, depending on incoming full domain.
+ * Only manages redirections to main home path.
+ *
* @param string $host
* @param array $domains_lang
* @param string $vhost