Ankur sood
New member
How to create Subdomains on the fly using .htaccess?
You could allow every subdomain in the first place and then check if the subdomain is valid. For example:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.example\.com$
RewriteRule !^index\.php$ index.php [L]
Inside the index.php you can than extract the subdomain using:
if (preg_match('/^([^.]+)\.example\.com$/', $_SERVER['HTTP_HOST'], $match)) {
var_dump($match[1]);
}
But all this requires that your webserver accepts every subdomain name.