Sorry for such a messy question name. The bottom line is this.

Suppose there is a table in the database, in the table there is a field with a specific value, how to transfer this value to the third level domain.

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

The page should be generated exclusively when requesting the database, without using files and folders where value will be the file (html, php, etc.) or a folder on the server.

I will add for clarity. There is a line in .htaccess

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

The result is a link http://mysite.com/value

how to implement the RewriteRule method so that http://value.mysite.com/ is equal to http://mysite.com/value and works the same.

  • Also interested in this question, created a file value.php, in .htaccess registered RewriteEngine on RewriteRule ^ ([a-z0-9 - /] +) $ _construct.php [L] And when I visit the link mysite.com/value Danver says there is no such page - dogmar
  • My example is not really worth following, I have a lot of muddling to work) - Palmervan
  • well, your example was helped, without knowing your muddiness) I just need to understand how _construct works in .htaccess - dogmar
  • _construct.php consists of classes that process the address line and provide information on a specific request. On a simple php, it will look something like this: Options + FollowSymlinks -Indexes -MultiViews // at the discretion of DirectoryIndex index.php RewriteEngine On RewriteBase / RewriteRule ^ ([a-z0-9 - /] +) $ index.php? Value = $ 1 [L] And at index.php GET request - Palmervan

2 answers 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); header($new_location); 

htaccess:

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

About% 1 not sure. But in theory, it should be exactly one.

  • Thank you, I will build a request. I am interested in the specifically processing line in the .htaccess file which will produce instead of mysite.com/value -> value.mysite.com - Palmervan
  • where% 1 may be $ 1. Went to stay.) - Palmervan
  • Not. the dollar would be if regular on the same line. Referring to condition - exactly percentage - knes

Without type A records in the domain settings in the DNS servers, you will not get any third-level domain .... Read here

  • This is all learned from the beginning! - Palmervan