Redirect of non-related sites on the same server with different URLS using Javascript

Discussion in 'Computer Support' started by UKALUM85, Jun 24, 2003.

  1. UKALUM85

    UKALUM85 Guest

    For those of you that want do it here's the code to redirect to different
    sites on a server from the main page in Javascript:

    <script language="JavaScript">
    <!--
    var dns1 = "http://mail.url1.com"
    var dns2 = "http://url1.com"
    var dns3 = "http://mail.url2.com"
    var dns4 = "http://url2.com"
    var dns5 = "http://mail.url3.com"
    var dns6 = "http://url3.com"
    var urlloc = location.href
    var loc = urlloc.toLowerCase()

    if ( loc.indexOf(dns1) != -1 ) {

    location.href = "http://url1.com:port"

    } else if ( loc.indexOf(dns2) != -1 ) {

    location.href = "http://url1.com/sitefolder"

    } else if ( loc.indexOf(dns3) != -1 ) {

    location.href = "http://url2.com:port"

    } else if ( loc.indexOf(dns4) != -1 ) {

    location.href = "http://url2.com/sitefolder2"

    } else if ( loc.indexOf(dns5) != -1 ) {

    location.href = "http://mail.url3.com:port"

    } else if ( loc.indexOf(dns6) != -1 ) {

    // Load Page
    }
    //-->
    </script>

    where urlx is the domain name, change mail and .com accordingly and port is
    the port of the web messaging for the mailserver or alternate web server
    port. Adding more urls is accomplished by incrementing the var dns lines and
    adding additional if statements with the redirects.


    This is what I was asking for 3 days ago, thought I'd post so others might
    benefit from my research and work.
     
    UKALUM85, Jun 24, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Splibbilla
    Replies:
    2
    Views:
    4,792
    Splibbilla
    Jul 23, 2005
  2. EG
    Replies:
    5
    Views:
    8,294
    Walter Roberson
    Dec 30, 2004
  3. Joe
    Replies:
    4
    Views:
    1,324
  4. amit_dabade
    Replies:
    0
    Views:
    660
    amit_dabade
    Jul 24, 2008
  5. CorpAmis
    Replies:
    1
    Views:
    1,222
    susith
    Apr 30, 2009
Loading...

Share This Page