-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·45 lines (37 loc) · 1.15 KB
/
Copy pathindex.php
File metadata and controls
executable file
·45 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
$languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$selectedLang = 'jp';
$selectableLangs = array(
'ja' => 'jp',
'en' => 'en',
'vn' => 'vn',
);
foreach ($languages as $lang) {
$lang = preg_replace('/^(..).*/u', '\1', $lang);
$lang = strtolower($lang);
if (array_key_exists($lang, $selectableLangs)) {
$selectedLang = $selectableLangs[$lang];
break;
}
}
doRedirect("./${selectedLang}/index.html");
/**
* リダイレクトを行う。
*
*
* @param
* @return
*/
function doRedirect($strUrl)
{
if (!headers_sent($filename, $linenum)) {
header("Location:".$strUrl);
exit;
// おそらく、ここでエラー処理を行うでしょう。
} else {
echo "$filename の $linenum 行目でヘッダがすでに送信されています。\n" .
"リダイレクトできません。代わりにこの <a " .
"href=\"http://www.example.com\">リンク</a> をクリックしてください。\n";
exit;
}
}