Skip to main content

How to check if subdomain exists using php?

Comments

2 comments

  • sparek-3
    There are some syntax errors in your script - you need to add a "; before the closing } bracket in the else statement. Are you sure that mysub.mydomain.com exists in /etc/localdomains? cat /etc/localdomains | grep mysub.mydomain.com Of course, this is also going to match if notmysub.mydomain.com exists in /etc/localdomains
    0
  • cPanelLauren
    While I can't give you PHP development advice specifically - The addsubdomain cPAPI2 function will provide an error in the event a subdomain exists already and allow creation if it doesn't which may be helpful: cPanel API 2 Functions - SubDomain::addsubdomain - Developer Documentation - cPanel Documentation
    0

Please sign in to leave a comment.