If you look at the URL of the habrahabr.ru user profile, you can see that the third level domain is his login. This approach is called “user virtual domains”.
Why about theoretical? Because in practice I did not manage to fully launch this technology: when I call vasya.site.ru/index.php, the browser offers to keep index.php, instead of executing it. There have been attempts to explicitly specify in .htaccess:
AddType application / x-httpd-php .php .htm .html
AddHandler x-httpd-php .php .htm .html
Options Indexes FollowSymLinks
DirectoryIndex index.html index.php
- but still to no avail.
In general, theoretically, it looks like this:
Adding an entry to the settings of the dns server of the form:
IP_ADDRESS * .site.ru
Add ServerAlias to httpd.conf for a domain:
<VirtualHost site.ru:80>
DocumentRoot / var /www/site.ru
ServerName site.ru
ServerAlias * .site.ru
</ Virtualhost>
Add to .htaccess:
RewriteEngine On
RewriteCond% {HTTP_HOST}! ^ Www.site.ru $
RewriteCond% {HTTP_HOST} ^ ((. *) \.) Site.ru $
RewriteRule ^ / (. *) /% 2 / $ 1
Or parse $ _SERVER ['HTTP_HOST']
')
PS: Strange, but there is not enough information on the network on the subject, is it really out of this approach that such a secret is made . PSR: Fasting is an issue with a tendency to an article.