如果网址不正确,如何重定向页面?

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();
}

You can use in your .htaccess:

RewriteEngine on
RewriteCond %{QUERY_STRING} lang= [NC]
RewriteCond %{QUERY_STRING} !lang=(?:hy|ru|en)(?:&|$) [NC]
RewriteRule ^ https://it-center.am/? [R=301,L]

For this, I would say you need to handle it using .php. I'll start by defining a list of valid codes and then if the request doesn't match it, I'll redirect it.

$valid = array("en", "ru", "hy");
if (!in_array($_GET["lang"], $valid)) {
  header("Location: ./?lang=en");
  die();
}