Results 1 to 4 of 4

Thread: wildcard sites

  1. #1
    Join Date
    Apr 2005
    Posts
    537

    wildcard sites

    hello,
    im trying to code a script whereby i can let users create their own virtual site automaticly (php copy files etc) using a subdomain like site.mydomain.net but obviously im going to be uisng wildcard dns to forward the subdomains to the ip of my server - currently i have a script their which detects the name of site (http_host var) and checks a mysql db to see if it exists but i cant work out how to forward from their to the users site without ending up with a link like site.mydomain.net/site which i obviously dont want- tried using the php chdir function but that doesnt work either

    current script thats being used as index.php is below
    PHP Code:
    <?php
    include("config.php");
    connectdb();

    $host=$_SERVER["HTTP_HOST"];
    $site=explode(".",$host);
    $query1=mysql_query("SELECT * FROM sites WHERE intname='".$site[0]."'");
    $sitecheck=mysql_num_rows($query1);
    if(
    $sitecheck==1)
        {
                    
    chdr($site[0]);
            
    header("Location: index.php");
        }else{
      
    header("Cache-Control: no-cache, must-revalidate");            // Prevent caching, HTTP/1.1
      
    header("Pragma: no-cache");
    echo 
    '<?xml version="1.0" encoding="UTF-8"?>'
    echo 
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <?php
    echo "<head>";
    echo 
    "<title>***</title>";
    echo 
    "
    <style type=\"text/css\">
    <!--

    body {
    color: #
    $txt;
    background-color: #
    $bgcol;
    text-align: center;
    font-family: 
    $txtstyle;
    font-size: 
    $sze;
    }
    a:link { color: #
    $lnk; }
    a:visited { color: #
    $lnk; }

    .profile {
    color: #
    $txt;
    background-color: #
    $bgcol;
    text-align: left;
    }
    a:link { color: #
    $lnk; }
    a:visited { color: #
    $lnk; }

    .breaker {
    color: #
    $txt;
    border-style: dashed;
    padding: 5;
    border-width: 1px;
    background-color: #
    $altbg;
    text-align: center;
    }
    a:link { color: #
    $lnk; }
    a:visited { color: #
    $lnk; }

    .form-container {
     text-align: center;
    }
    img
    {  border-style: none;
    }
    -->
    </style>

    </head>"
    ;
    echo 
    "<body><p>";
            echo 
    "Sorry Theirs no site here by that name<br/> Feel Free To Click <a href=\"http://www.****.net/create.php\">Here</a> To Make One";
    echo 
    "</p></body></html>";
        }

    ?>
    excuse the seeminly weird css etc - its going to be a xhtml mobile based site so im trying to keep it valid

  2. #2
    Join Date
    Apr 2005
    Posts
    537
    no one with any ides ?

  3. #3
    does it have to be a script or are you on your own server (or vps) such that you have full control over httpd.conf?

  4. #4
    Join Date
    Apr 2005
    Posts
    537
    can be a shell script etc, i use litespeed not apache though so no httpd.conf as such, and i want to be able to copy files to create the site automaticly also

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •