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.

Automatic Create Subdomain - www.cpanelusername.hostname

Discussion in 'General Discussion' started by jaro74, Oct 16, 2011.

  1. jaro74

    jaro74 Member

    Joined:
    Oct 10, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Whether it is possible to automatically create subdomain like "www.cpanelusername.hostname" when i create new account for client. Can it be done in cPanel DNS zone template?

    Please help

    My DNS zone template

    Code:
    ; cPanel %cpversion%
    ; Zone file for %domain%
    $TTL %ttl%
    @      %nsttl%	IN      SOA     %nameserver%. %rpemail%. (
    		%serial%	; serial, todays date+todays
    		86400		; refresh, seconds
    		7200		; retry, seconds
    		3600000		; expire, seconds
    		86400 )		; minimum, seconds
    
    %domain%. %nsttl% IN NS %nameserver%.
    %domain%. %nsttl% IN NS %nameserver2%.
    %domain%. %nsttl% IN NS %nameserver3%.
    %domain%. %nsttl% IN NS %nameserver4%.
    
    %nameserverentry%. IN A %nameservera%
    %nameserverentry2%. IN A %nameservera2%
    %nameserverentry3%. IN A %nameservera3%
    %nameserverentry4%. IN A %nameservera4%
    
    %domain%. IN A %ip%
    
    localhost.%domain%. IN A 127.0.0.1
    
    %domain%. IN MX 0 %domain%.
    
    mail IN CNAME %domain%.
    www IN CNAME %domain%.
    ftp IN CNAME %domain%.
    
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You could use a /scripts/postwwwacct script to automatically create a subdomain for the account on account creation. This would likely be easier to perform than trying to modify the zone template to add that domain, because the zone templates do not recognize the cPanel username as a field type.
     
  3. jaro74

    jaro74 Member

    Joined:
    Oct 10, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    and whether it is possible add other parameter(field name) to dns zone template to auto create subdomain?

    in place subdomain add clientdomainname without dots


    example clientdomainname.tld >>>>>> clientdomainname.hostname ?

    the point is that the client using a temporary subdomain before park domain own domain
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The issue here is that the %domain% entry contains the tld in it such as .com or .net or whatever it might be, so you cannot simply do:

    %domain%.server.domain.com.

    Where server.domain.com represents the hostname. The better option is truly to use /scripts/postwwwacct to create an A record entry to point some subdomain based on variables into the zone file.
     
  5. jaro74

    jaro74 Member

    Joined:
    Oct 10, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Can you please explain what a file /scripts/postwwwacct and how to use it. I'm new in cp . regards
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  7. jaro74

    jaro74 Member

    Joined:
    Oct 10, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    [root /scripts]# ls -la
    total 5264


    I dont have file /scripts/postwwwacct

    ?

    Can you please create for me postwwwacct and add code for
    automate subdomain creation

    for example
    www.hostname/~cpusername --------> www.cpusername.hostname



    Regards
     
    #7 jaro74, Oct 27, 2011
    Last edited: Oct 27, 2011
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The file /scripts/postwwwacct does not exist by default but is a hook you can create for using after account creation. You would need to create the script to automatically create the subdomain. That is something you should be researching as the system administrator and developer of your system. If you want to ask questions after you've researched the documentation Michael provided on code you've worked on creating, please definitely feel free to ask.

    The purpose of this forum isn't to provide cut and paste examples of coding for all functions, but to point you in the direction to learn how to administer and develop specialized content for your own machine.
     
Loading...

Share This Page