Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Member mahdionline's Avatar
    Join Date
    Oct 2003
    Posts
    127

    Cool Create subdomain with a php script

    Hi

    I want to write a script with php that create subdomain in a cpanel(linux redhat 7.3) server.

    can anyone help me !

    Regard
    Mahdionline

  2. #2
    Member
    Join Date
    Feb 2004
    Posts
    204

    Smile

    Hi mahdionline,

    Have a patience to read the script.Please follow up this script for your problem,which will help you.

    <?
    ################################################## ###################
    # Subdomains 0,51
    # Released under the terms of the GNU General Public License.
    # Please refer to the README file for more information.
    ################################################## ###################

    ################################################## ###################
    # PLEASE EDIT THE FOLLOWING VARIABLES:
    ################################################## ###################

    # Your domain name. NO "www." IN FRONT OF IT. NO SLASHES ("/").
    # Just the actual domain name, i.e. "yourdomain.com"
    $domain = "oe-design.com";

    # The default page that the visitors should be redirected to if
    # they don't request a sub domain or they request a non-existing
    # sub domain. This page could be named "welcome.html",
    # "front_page.html" or something similar. The page should be
    # located in your document root. If you can view the page by
    # entering "http://yourdomain.com/welcome.html" in your browser,
    # then it is located in the document root.
    $default_page = "welcome.html";

    # Do you want to use frames?
    $use_frames = "yes";

    ################################################## ###################
    # THAT'S IT! NO MORE EDITING NECESSARY.
    ################################################## ###################



    $underdomaene = $HTTP_HOST;
    $underdomaene = eregi_replace("\.".$domain, "", $underdomaene);
    $underdomaene = eregi_replace("www\.", "", $underdomaene);
    $underdomaene = strtolower($underdomaene);

    # If the sub domain is the name of a directory in the document root...
    if (is_dir("$DOCUMENT_ROOT/$underdomaene")) {
    # The frames version:
    if ($use_frames == "yes") {
    echo "<html><head><title>$domain/$underdomaene</title>\n\n";
    echo "<!---------------------------------------------------------------------\n";
    echo " The sub domains at $domain were created using\n";
    echo " the PHP script \"Subdomains\"\n";
    echo "---------------------------------------------------------------------->\n\n";
    echo "</head>\n\n\n\n";
    echo "<frameset cols=100%,* frameborder=no border=0 framespacing=0>\n";
    echo "<frame src=http://$domain/$underdomaene>\n";
    echo "<noframes>\n";
    echo "<body bgcolor=black link=silver alink=black vlink=gray>\n";
    echo "<font face=helvetica color=white><center>\n";
    echo "This page uses frames, but it seems that your browser does not support this feature.\n";
    echo "To move on, click here:<br><a href=http://$domain/$underdomaene>$domain/$underdomaene</a>\n";
    echo "</center></font>\n";
    echo "</body>\n";
    echo "</noframes>\n";
    echo "</frameset></html>\n";
    }

    # The non-frames version:
    else {
    header("Location: http://$domain/$underdomaene");
    }
    }

    # If the sub domain is NOT the name of a directory in the document root...
    else {
    if (!$REQUEST_URI || $REQUEST_URI == "/") {
    include("$DOCUMENT_ROOT/$default_page");
    }
    else {
    header("Location: http://$domain$REQUEST_URI");
    }
    }
    ?>


    Please check it. May be it will help you.

    Regards,

Similar Threads & Tags
Similar threads

  1. how can we create subdomain through php dynamically
    By sweta in forum New User Questions
    Replies: 4
    Last Post: 07-20-2009, 10:32 AM
  2. Create subdomain and FTP user account using PHP
    By MarkCool in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-01-2008, 12:52 PM
  3. create subdomain (using php)
    By SIFE in forum New User Questions
    Replies: 1
    Last Post: 06-23-2008, 01:51 PM
  4. Create SUBDOMAIN via PHP script
    By mlotfi63 in forum New User Questions
    Replies: 0
    Last Post: 12-28-2006, 11:28 PM
  5. Create Subdomain With PHP
    By erictham in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 02-04-2004, 08:36 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube