     return err "Invalid domain: #{domain}"  unless match
     [rest..., prefix, slug] = match
 
+    if slug isnt nickname
+      return err "Creating root domains is not allowed"
+
+    slug = "koding"  if nickname is slug
+    if group? and group isnt slug
+      return err "Invalid group"
+
     # Return type as internal and slug and domain
-    return {type: 'internal', slug, prefix, domain}
+    return { type: 'internal', slug, prefix, domain }
 
 
   resolveDomain = (domain, callback, check)->

      return error "Domain is not provided"

    {delegate} = client.connection
    {err, domain, type, slug, prefix} = parseDomain domain

    return callback err  if err

    {group}    = client.context
    {nickname} = delegate.profile

    if type is 'internal'

      if slug isnt nickname
        return error "Creating root domains is not allowed"

      slug = "koding"  if nickname is slug
      unless group is slug
        return error "Invalid group"

    JDomain.one {domain}, (err, model)->
      return callback err  if err

      callback null, filterDomains domains, delegate, group


  parseDomain = (domain, { nickname, group })->

    { userSitesDomain } = KONFIG

