diff --git a/administrator/language/en-GB/en-GB.plg_system_languagefilter.ini b/administrator/language/en-GB/en-GB.plg_system_languagefilter.ini
index 1c2b264f2ddb4..c90f083e9e4b9 100644
--- a/administrator/language/en-GB/en-GB.plg_system_languagefilter.ini
+++ b/administrator/language/en-GB/en-GB.plg_system_languagefilter.ini
@@ -15,6 +15,8 @@ PLG_SYSTEM_LANGUAGEFILTER_FIELD_DETECT_BROWSER_DESC="Choose site default languag
PLG_SYSTEM_LANGUAGEFILTER_FIELD_DETECT_BROWSER_LABEL="Language Selection for new Visitors"
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_DESC="This option will allow item associations when switching from one language to another."
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_LABEL="Item Associations"
+PLG_SYSTEM_LANGUAGEFILTER_FIELD_REDIRECT_CODE_DESC="This option will allow to set the redirect HTTP code for language redirects."
+PLG_SYSTEM_LANGUAGEFILTER_FIELD_REDIRECT_CODE_LABEL="Redirect HTTP Code"
PLG_SYSTEM_LANGUAGEFILTER_FIELD_XDEFAULT_DESC="This option will add x-default meta tag to improve SEO."
PLG_SYSTEM_LANGUAGEFILTER_FIELD_XDEFAULT_LABEL="Add x-default Meta Tag"
PLG_SYSTEM_LANGUAGEFILTER_FIELD_XDEFAULT_LANGUAGE_DESC="Choose the x-default language."
diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php
index b3a707aad4b96..2b4a8c7e8623e 100644
--- a/plugins/system/languagefilter/languagefilter.php
+++ b/plugins/system/languagefilter/languagefilter.php
@@ -378,13 +378,6 @@ public function parseRule(&$router, &$uri)
}
}
- // Don't cache the redirect in browser.
- $this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
- $this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
- $this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
- $this->app->setHeader('Pragma', 'no-cache');
- $this->app->sendHeaders();
-
if ($this->mode_sef)
{
// Use the current language sef or the default one.
@@ -401,13 +394,29 @@ public function parseRule(&$router, &$uri)
$uri->setPath('index.php/' . $uri->getPath());
}
- $this->app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')), 301);
+ $redirectUri = $uri->base() . $uri->toString(array('path', 'query', 'fragment'));
}
else
{
$uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
- $this->app->redirect($uri->base() . 'index.php?' . $uri->getQuery(), 301);
+ $redirectUri = $uri->base() . 'index.php?' . $uri->getQuery();
+ }
+
+ // Get the redirect code from plugin parameters. Defaults to 302.
+ $redirectHttpCode = (int) $this->params->get('redirect_code', 302);
+
+ // If redirect code is cachable by default (301 or 308), don't cache the redirect in browser.
+ if (in_array($redirectHttpCode, array(301, 308))
+ {
+ $this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
+ $this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
+ $this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
+ $this->app->setHeader('Pragma', 'no-cache');
+ $this->app->sendHeaders();
}
+
+ // Redirect to language.
+ $this->app->redirect($redirectUri, $redirectHttpCode);
}
// We have found our language and now need to set the cookie and the language value in our system
diff --git a/plugins/system/languagefilter/languagefilter.xml b/plugins/system/languagefilter/languagefilter.xml
index 517801dcb9769..52268828b6410 100644
--- a/plugins/system/languagefilter/languagefilter.xml
+++ b/plugins/system/languagefilter/languagefilter.xml
@@ -102,7 +102,6 @@
-
PLG_SYSTEM_LANGUAGEFILTER_OPTION_YEAR
+
+
+
+
+
+
+
-
\ No newline at end of file
+