Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

Can´t access subdomain, after creating it in cPanel with PHP

Discussion in 'General Discussion' started by nicop8, Apr 26, 2014.

  1. nicop8

    nicop8 Registered

    Apr 26, 2014
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Website Owner
    I have a website where the user create his own site, and for that i need to create a subdomain. My server has cPanel, so I´m creating the subdomain in cPanel using PHP code. The problem is that the subdomain is created correctly and the folder in the server too, but when i try to access it the server is not found. The subdomain doesn´t create in the DNS file zone by this way.

    I haven´t got the problem if I create the subdomain manually with the cPanel interface. In this case i can access to the subdomain. My hosting is Godaddy.

    I'm using the next php code:

    $pass base64_encode("$cpanel_user:$cpanel_pass");
    $in "GET /frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$cpanel_host&domain=$subdomain&dir=public_html/subdomains/$subdomain\r\n";
    $in .= "HTTP/1.0\r\n";
    $in .= "Host:$cpanel_host\r\n";
    $in .= "Authorization: Basic $pass\r\n";
    $in .= "\r\n";
    while (!
    feof($sock)) {
    $result .= fgets ($sock,128);
    The code is working, because the subdomain appears in cPanel. But I can´t acces to it. Do you know what´s the problem? I haven´t got any problem in other servers, but i have this problem in godaddy.

  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hello :)

    I recommend contacting your web hosting provider for assistance with this issue. It's possible they have custom security features in-place that prevent the successful creation of the subdomain through the cPanel API. Or, there could be a specific error message in the cPanel error log that they can investigate.

    Thank you.

Share This Page