如何让我的用户拥有自定义域名? [关闭]

I would like to create a feature that allow my users to have custom domain. Like what blogger/wordpress is doing.

e.g.

http://www.domain.com

User can have own custom domain

http://www.custom.com

In which typing in www.custom.com maps to www.domain.com

How do i do so? I am using php. Is this a server configuration?

You need to have to change the DNS of the new site to forward to their site.

I do this with my multi-account platform. I use the cpanel api to create an add-on domain each time they specify their domain name and I ask them to change the name-servers on their domain to my hosting. So here's an example: www.example.com ask user to change nameservers to ns1.hostingwerks.com and ns2.hostingwerks.com prompt user for their domain use api to add on their domain tell user it's done but allow some time for it to propigate This requires you to have whm access, but it might give you some help.

if(!empty($domain) AND $olddomain != $domain){

    $d = explode(".",$origdomain);
    if(count($d) != 1){
    if($d[0] == "www" OR $d[0] == "http://www" OR $d[0] == "https://www"){
    $origdomain = $d[1] .".". $d[2];
    }
    else {
    $origdomain = $d[0] .".". $d[1];
    }
    }
    if(substr($origdomain, 0, 8) == "https://"){
    $origdomain = substr($origdomain, 8);
    }
    elseif(substr($origdomain, 0, 7) == "http://"){
    $origdomain = substr($origdomain, 7);
    }
    $dom = $origdomain;
    $user = "your cpanel client username";
    $addonpass = "your new domain's password";
    $cpanel_skin = "x3";
    $passw = "your cpanel password";
    $ownername = "your cpanel hosting user name";
    $pass = "your cpanel password";
    $host = "localhost";
    //Using 'explode' breaks the domain into its constituent pieces, the name and the extension (TLD), and puts them in an array
    $domai = explode('.',$dom);
    /*the directory path is defined by the first element appended to public_html.  It does not matter where this file, 'addonhelper.php', is located - 
    the program will always install the addon domains to this directory.  If this needs to be changed, this line needs to be updated.
    Some versions of Cpanel do not allow for this to be changed and will ignore changes.  Most notably - version X.*/
    $dir="public_html/sys";
    //the user is the first element of the $domain, as requested
    $user=trim($domai[0]);
    //put the domain back together and trim whitespace.
    $dom=trim($domai[0]).".".trim($domai[1]);
    //create the cpanel request.
    $request = "/frontend/$cpanel_skin/addon/doadddomain.html?domain=$dom&user=$user&dir=$dir&pass=$addonpass";
    //process the request with addondomain below
    $sock = @fsockopen($host,2082);
    if(!$sock) {
        print('Socket error');
        exit();
    }
    //authenticate the connection
    $authstr = "$ownername:$passw";
    //make the passphrase slightly more difficult to decipher
    $pass = base64_encode($authstr);
    $in = "GET $request
";
    $in .= "HTTP/1.0
";
    $in .= "Host:$host
";
    $in .= "Authorization: Basic $pass
";
    $in .= "
";
    //process
    fputs($sock, $in);
    while (!feof($sock)) {
        $result .= fgets ($sock,128);
    }
    fclose( $sock );

If you're just looking to change a single domain, change the nameservers on it to the same, and set it up as an add on in your plesk/cpanel to the same folder. Or you can forward the domain and mask it. That works too. http://support.godaddy.com/help/article/422/forwarding-or-masking-your-domain-name