multi-domain recognition at db level I have:


2 domains
single database
Single codebase
single form with a text-editor and submit button.


What I want is the recognition of domain at database level. So, let's say if I hit http://example.com/en it should save in db with table T1 and if I hit http://example.fr/en it should also save in same db but with different table T2.

And now when I will fetch default value from table T1, it should only reflect to http://example.com/en and similarly for T2 it goes here - http://example.fr/en.

But because of same database and code base of both domains it is difficult to know from which domain the request is coming.

I have 1 solution is like create a table in .install file by considering global $base_url; and then check if table name = $base_url.my_table exists, fetch all results.But I'm not sure it's the best approach in Drupal 8 or some other way to achieve this.

Please share best approach for this.
You need to enable multisite. 

The documentation inside the settings.php file is also very helpful, read that too by viewing the source of the file here https://api.drupal.org/api/drupal/sites!default!default.settings.php/8.

Briefly, the steps are,


Multi-site requires the existence of the sites/sites.php file in your Drupal 8 installation. You will need to create this file manually.


Example content would be:

&lt;?php
$sites['mysite.com'] = 'site1';
$sites['8000.localhost'] = 'site2';



Create a site directory inside sites/, the path should be sites/site1.
Put a settings.php file in this directory in order for Drupal 8 to recognize it.
Visit the URL of site1, like mysite.com to install it.