我的网页上有两种语言。这些是en和rs。即英语和俄语。我希望在languages目录下列为en.php和rs.php,但前提是它们的格式为url = ln = I,例如www.google.com/en或www.google.com/rs。为此,我添加了.htaccess文件和function.php文件。但我不知道如何更改我在下面写的代码。我怎么能这样做?
我有语言文件夹和en.php和tr.php
<?php
# Session başlat
session_start();
$available_langs = array('en','tr');
$_SESSION['lng']='en';
# Dil seçimi yapılmışsa
if($_GET['lng']) {
# Dil seçimini session'a ata.
$_SESSION['lng'] = $_GET['lng'];
# Anasayfa'ya yönlendir.
}
if ($_SESSION['lng'] == "en") {
$lng = "en";
}
elseif ($_SESSION['lng'] == "tr") {
$lng = "tr";
}
include 'languages/'.$lng.'.php';
include("fonksiyon.php");
?>
<li>
<?php
if(isset($_GET["lng"])){
if($_GET["lng"] == "tr"){
//echo '<a href="?lng=en" style="text-decoration:none;" title="English">EN</a>';
echo ' <li style="float:left"> <a href="?lng=en"
style="border-left: solid gray 1px; line-height: 50%; margin-top: 15px; padding-right:2px; ">EN</a></li>';
} else if($_GET["lng"] == "en"){
// echo '<a href="?lng=tr" style="text-decoration:none;" title="Türkçe">TR</a>';
echo ' <li style="float:left"> <a href="?lng=tr"
style="border-left: solid gray 1px; line-height: 50%; margin-top: 15px; padding-right:2px; ">TR</a></li>';
} else {
echo 'no lang';
}
} else {
// echo '<a href="?lng=tr" style="text-decoration:none;" title="Türkçe">TR</a>';
echo ' <li style="float:left"> <a href="?lng=tr" style="border-left: solid gray 1px;
line-height: 50%; margin-top: 15px; padding-right:2px; ">TR</a></li>';
}
?>
</li>
的.htaccess
RewriteEngine On
RewriteRule ^(.*)-(.*).html$ roportajdetay.php?id=$1&$baslik=$2 [L,NC]
fonksiyon.php
<?php function cevir($s) {
$tr = array('ş','Ş','ı','İ','ğ','Ğ','ü','Ü','ö','Ö','Ç','ç');
$eng = array('s','s','i','i','g','g','u','u','o','o','c','c');
$s = str_replace($tr,$eng,$s);
$s = strtolower($s);
$s = preg_replace('/&.+?;/', '', $s);
$s = preg_replace('/[^%a-z0-9 _-]/', '', $s);
$s = preg_replace('/s+/', '-', $s);
$s = preg_replace('|-+|', '-', $s);
$s = trim($s, '-');
return $s;
} ?> ?>