php help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ztik
    Confirmed User
    • Aug 2001
    • 5196

    #1

    php help

    anyone know how to take a subdomain sub and put it into a link

    IE

    I have the domain

    http://SUB.domain.com

    I want to take a sub domain and make it at the end of a link

    http://www.someotherdomain.com/SUB
    .
  • nestle
    Confirmed User
    • Apr 2006
    • 647

    #2
    Code:
    <?
    // this separates it into an array [0]=>sub, [1]=>domain, [2]=>tld
    $exploded = explode(".", $_SERVER['HTTP_HOST']);
    
    // just redirects to http://someotherdomain.com/sub
    header("Location: http://www.someotherdomain.com/" . $exploded[0]);
    ?>
    untested but should work.
    Last edited by nestle; 03-27-2007, 06:15 PM.

    Comment

    • ztik
      Confirmed User
      • Aug 2001
      • 5196

      #3
      Originally posted by nestle
      Code:
      <?
      // this separates it into an array [0]=>sub, [1]=>domain, [2]=>tld
      $exploded = explode(".", $_SERVER['HTTP_HOST']);
      
      // just redirects to http://someotherdomain.com/sub
      header("Location: http://www.someotherdomain.com/" . $exploded[0]);
      ?>
      untested but should work.

      cool i'll try it, thanks for the help
      .

      Comment

      Working...