R
R
Roman2019-02-11 21:31:48
Laravel
Roman, 2019-02-11 21:31:48

Serving two domains with one Laravel at the same time (multisiting) - how to do it?

Hello.
There are two third-level domains sub.site1.ru and sub.site2.ru.
You need to set up an essentially identical service on them, but with slight differences in design for each site, and a little different functionality (at the controller level).
Is it possible to somehow resolve this within a single Laravel application?
And if - "Yes" - then what exactly should be written in the routes?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-02-12
@procode

Thanks to Alex Wells , the solution seems to be found:

Route::domain('sub.{domain}.ru')->group(function () {
    Route::get('domaintest', function ($domain) {
        dd($domain);
    });
});

we pass the domain name to the [controller] function and then according to the situation.
However, probably, if so, you could just take it from $_SERVER and not worry about it :D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question