# Multiple domain, one core

**URL:** <https://discourse.cakephp.org/t/multiple-domain-one-core/8169>\
**Category:** Need Help\
**Created:** [August 3, 2020, 11:58am UTC](https://discourse.cakephp.org/t/multiple-domain-one-core/8169 "2020-08-03T11:58:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadowx.jb](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shadowx.jb](https://discourse.cakephp.org/u/shadowx.jb)\
**Post date:** [August 3, 2020, 11:58am UTC](https://discourse.cakephp.org/t/multiple-domain-one-core/8169/1 "2020-08-03T11:58:20Z")

</div>

Is it possible to have one core and multiple domains? E.g. for the English language the domain will be [www.domain1.com](http://www.domain1.com) for the Polish language the domain will be [www.domain2.com](http://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](http://www.domain1.com) in case I switch to Polish?

If I would like to have more domains in the project, eg [www.domain3.com](http://www.domain3.com) will display different content, how to define?

Thank you

---

<div class="post-metadata">

**Author:** ![ishan](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ishan/32/2589_2.png) [@ishan](https://discourse.cakephp.org/u/ishan)\
**Post date:** [August 3, 2020, 4:04pm UTC](https://discourse.cakephp.org/t/multiple-domain-one-core/8169/2 "2020-08-03T16:04:34Z")

</div>

Hi @shadowx.jb,

You can leverage [prefix routing](https://book.cakephp.org/3/en/development/routing.html#prefix-routing) for this.

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

```php
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.
