→ threeus: 你是要按國家分流嗎? 05/25 05:06
以下這串code是我目前拿來轉址用的php
因為server都不是固定IP,所以必須使用ddns網址
請問有辦法把這php用rewrite改成.htaccess嗎?
主要是因為client端的網址會被header改變,但我想要它能維持原網址
<?php
$server1 = gethostbyname('server1.ddns.net');
$server2 = gethostbyname('server2.ddns.net');
$clientIP = $_SERVER['REMOTE_ADDR'];
$admin = gethostbyname('admin.ddns.net');
if(($clientIP == $server1) || ($clientIP == $server2)) {
header('Location: http://www.url1.com');
exit();
}
else if($clientIP == $admin) {
header('Location: http://www.url2.com');
exit();
}
else {
header('Location: http://www.url3.com');
exit();
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.127.195.161
※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1430617292.A.8FD.html
※ 編輯: hanconquer (59.127.195.161), 05/03/2015 09:42:36