Multiple domain, one core

Is it possible to have one core and multiple domains? E.g. for the English language the domain will be www.domain1.com for the Polish language the domain will be www.domain2.com, how please set up the routes to make it work this way? Then, if I call another language page in the project, how is it listed that it is www.domain1.com in case I switch to Polish?

If I would like to have more domains in the project, eg www.domain3.com will display different content, how to define?

Thank you

Hi @shadowx.jb,

You can leverage prefix routing for this.

First you should add condition in your routes.php file to dynamically decide the prefix. For example:

if ($_SERVER['HTTP_HOST'] === 'domain1.com') {
    $prefix = 'en';
} elseif ($_SERVER['HTTP_HOST'] === 'domain2.com') {
    $prefix = 'es';
}

And then pass as prefix routing.

Then you can get the prefix in your controller to dynamically set translation language.

One thing with this approach is you end up creating particular prefix route specific controller along with your main controller that you should inherit to. So you can handle any prefix specific logic into its own controller.

2 Likes