[JS] URL에 따라 다른 페이지로 리다이렉트

<!DOCTYPE html>
<html lang="ko">
 <head>
  <meta charset="UTF-8">
  <meta http-equiv="Expires" content="-1">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="No-Cache">
  <title>URL에 따라 다른 페이지로 리다이렉트</title>
 </head>
 <body>

<script type="application/javascript">
    var ip_addr;

    function getIP(json) {
        ip_addr = json.ip;
    }
</script>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
<script type="application/javascript">
    function redirect_page() {
        var url = window.location.href;
        var no_search = true;

        check_url = url.indexOf("nas.esvali.com");
        if (check_url != -1) {
            no_search = false;
            if (ip_addr.indexOf("211.196.252.87") != -1) {
                window.location.href = "http://10.10.10.2";
                return 0;
            } else {
                window.location.href = "http://nas.esvali.com:6060";
                return;
            }
        }

        check_url = url.indexOf("seetrol.esvali.com");
        if (check_url != -1) {
            no_search = false;
            if (ip_addr.indexOf("211.196.252.87") != -1) {
                window.location.href = "http://10.10.10.101:7070";
                return;
            } else {
                window.location.href = "http://seetrol.esvali.com:7070";
                return;
            }
        }

        if (no_search)
            window.location.href = "http://www.esvali.com";
    }
    redirect_page();
</script>
 </body>
</html>
위로 스크롤