.htaccess third-level domain from the entry in the database

Sorry for such a svabnoy name. The essence is as follows.

Let’s say there is a table in the database, there is a field in the table with a specific value, as the value to transfer to the third level domain.

For example: http://mysite.com/value Display as http://value.mysite.com/

Page should be generated exclusively when requesting to the database, without using files and folders where Value will be file (HTML, PHP, other) or folder on the server.

Supplement for clarity.
In .htaccess there is a string

RewriteRule ^([a-z0-9-/]+)$ _construct.php [L]

In the end, it turns out the link http://mysite.com/value

As the rewriterule method, to implement http://value.mysite.com/ was http://mysite.com/value and worked equally.

Answer 1, Authority 100%

Without type a records in setting up a domain in the DNS servers, there are no third-level domain to you …. Read here

Answer 2

$res = mysql_query('select `value` from `locations` where `user_id`=777');
$row = mysql_fetch_object($res);
$new_location = sprintf('Location: http://%s.mysite.com/',$row->value);


RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$
RewriteRule ^ http://example.com/%1%{REQUEST_URI} [L,P]

About% 1 Not sure. But in the idea, there must be exactly one.