You need to generate a subdomain when you click on the button ( случайный-поддомен.site.com ). Here is the string generator:
function rand_string( $length = 8, $repeat = false, $UpperCase = true, $LowerCase = true, $Symbols = true, $SymbolsList__ = '0123456789-', $UpperCaseList = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', $LowerCaseList = 'abcdefghijklmnopqrstuvwxyz') { if ($UpperCase) { $UpperCase = $UpperCaseList; } if ($LowerCase) { $LowerCase = $LowerCaseList; } if ($Symbols) { $Symbols = $SymbolsList__; } unset($UpperCaseList, $LowerCaseList, $SymbolsList__); switch (rand(0, 5)) { case 0: $All = $UpperCase . $LowerCase . $Symbols; case 1: $All = $UpperCase . $Symbols . $LowerCase; case 2: $All = $Symbols . $LowerCase . $UpperCase; case 3: $All = $Symbols . $UpperCase . $LowerCase; case 4: $All = $LowerCase . $Symbols . $UpperCase; case 5: $All = $LowerCase . $UpperCase . $Symbols; } unset($UpperCase, $LowerCase, $Symbols); $totalLength = strlen($All) - 1; if (!$repeat) { $totalLength++; if ($length > $totalLength) { // echo "Error while generating the string: the maximum length is exceeded ($length instead of $totalLength characters)"; return false; } $totalLength--; while ($i++ < $length) { $Current = $All{rand(0, $totalLength--) }; $All = str_replace($Current, '', $All); $string.= $Current; } } else { while ($i++ < $length) { $string.= $All{rand(0, $totalLength) }; } } unset($All, $i, $length, $totalLength, $repeat); return $string; } echo rand_string() Suppose the generated value is lhtjnz23 . How to assign this value to the domain .site.com so that it is lhtjnz23.site.com ?