For example if after question mark there is another word, it redirects to home page.
After question mark there can be only the word lang=hy
or lang=ru
or lang=en
:
https://it-center.am/?lang=hy
But otherwise it should redirect to home page. For example there can not be url like this:
https://it-center.am/?lang=hyyy
Should I change something in .htaccess
?
Here is code of languages.php
define('LANGUAGE_DIR', $_SERVER['DOCUMENT_ROOT']."/language/", false);
define('TEMPLATE_DIR', $_SERVER['DOCUMENT_ROOT']."/", false);
$languages = [
"hy",
"ru",
"en",
];
session_start();
if (!isset($_SESSION['lang']) OR !isset($_GET['lang']))
{
$_SESSION['lang'] = $languages[0];
$language = $_SESSION['lang'];
}
else {
$language = $_GET['lang'];
}
include_once(LANGUAGE_DIR . $language . '.php');
$valid = array("en", "ru", "hy");
if (!in_array($_GET["lang"], $valid)) {
header("Location /index.php?lang=hy");
die();
}