The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

subdomain help

Discussion in 'General Discussion' started by icebaby, May 21, 2004.

  1. icebaby

    icebaby Registered

    Joined:
    May 21, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
  2. Jeff-C

    Jeff-C Well-Known Member

    Joined:
    Mar 16, 2004
    Messages:
    117
    Likes Received:
    0
    Trophy Points:
    16
  3. earthquakie

    earthquakie Member

    Joined:
    Jun 7, 2003
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Florida
    I have an answer to part of your question and is actually something I have done for some time and is pretty straight forward. It is actually a subdomain redirect utilizing a users directory as the subdomain, under a set directory(nice for the times you need to get into the root, you don't have to wait for 100's of user directories to list).

    Now I do not know who the original author is and couldn't even claim to have done it, but I had to make some simple mods to make it work on my server with WHM/CPanel. I have made sure the comments are current as to the mods I had to make, so simply follow the comments and you will be utilizing it within minutes.

    As to what you use to actually automate the creation of the directories you will need to find another script to handle it, as I paid for a redirect script to allow the creation of redirects using this wildcard subdomain script as the front end to browser requests.

    <?


    #####################################################################

    # TO UTILIZE WILDCARD SUBDOMAINS WHICH REDIRECT TO A USER DIRECTORY
    # UNDER A SUB DIRECTORY YOU MUST EDIT THE FOLLOWING VARIABLES BELOW
    # AND EDIT TO ADD THE WILDCARD TO THE DNS ENTRY IN WHM LIKE:
    # DOMAIN TTL RECORD TYPE
    # * 14400 CNAME yourdomain.com.
    # DO NOT FORGET THE PERIOD AFTER yourdomain.com

    #####################################################################


    # Your domain name WITHOUT the "www." NO TRAILING SLASHES ("/")
    # Just the actual domain name: "yourdomain.com"

    $domain = "yourdomain.com";


    # The relative path to your users directory, ex:
    # if your users directory is installed in yourdomain.com/users you
    # should enter only $userdir = "user";

    $userdir = "user";


    # The default page that the visitors should be redirected to if
    # they don't request a subdomain or they request a non-existing
    # subdomain. This page should be your main index page. You can
    # simply rename your existing index.html file to main.html This
    # index.php file must be the default file that users are first
    # directed on your site, so you must remove any other index.html or
    # index.xxx file that may conflict. The main.html page should be
    # located in your document root:"http://yourdomain.com/main.html"

    $default_page = "main.html";


    # Do you want to use frames?

    $use_frames = "no";






    #############################################################################

    # CONFIGURATION ALMOST COMPLETE... ONLY EDIT yourdomain.com BELOW HERE

    #############################################################################

    $sub = $HTTP_HOST;
    $sub = eregi_replace("\."."yourdomain.com", "", $sub);
    $sub2 = $sub;
    $sub = eregi_replace("www\.", "", $sub);
    $sub = strtolower($sub);

    if (!(is_dir("$DOCUMENT_ROOT/$userdir/$sub"))) { $sub = $sub2; }


    if (is_dir("$DOCUMENT_ROOT/$userdir/$sub")) {
    if ($use_frames == "yes") {
    echo "<html><head><title>$sub</title>\n";
    echo "</head>\n";
    echo "<frameset cols=100%,* frameborder=no border=0 framespacing=0>\n";
    echo "<frame src=http://yourdomain.com/$userdir/$sub>\n";
    echo "<noframes>\n";
    echo "<body bgcolor=#FFFFFF>\n";
    echo "<br><br><font face=verdana size=2><center>\n";
    echo "This page uses frames, but it seems that your browser does not support this feature.\n";
    echo "<br><br>To move on, click here: <a href=http://yourdomain.com/$userdir/$sub>$sub.$domain</a>\n";
    echo "</center></font>\n";
    echo "</body>\n";
    echo "</noframes>\n";
    echo "</frameset></html>\n";
    }
    else {
    header("Location: http://yourdomain.com/$userdir/$sub");

    }
    }
    else {
    if (!$REQUEST_URI || $REQUEST_URI == "/") {
    include("$DOCUMENT_ROOT/$default_page");
    }
    else {
    header("Location: http://yourdomain.com$REQUEST_URI");
    }
    }
    ?>

    Enjoy :D
     
Loading...

Share This Page