1

I have a dedicated server that is running Nginx as a webserver. I also have 3 domain names, for example www.domainnameA.com, www.domainnameB.com, and www.domainnameC.com

What i want to be able to do is run one Laravel 5.6 codebase, but somehow know if someone hits a route on domainnameA.com it should point to a specific place.

I know currently that Laravel can do subdomain routing;

Route::domain('{account}.myapp.com')->group(function () {}

But is there any way to do different domains completely.

And also be able to share credentials between them. i.e if a person logs in to domainnameA.com and then heads over to domainnameC.com they will still be logged in as the same user.

Can this be done with a mixture of nginx and laravel?

1 Answers1

0

You can catch the domain just like a subdomain

Route::group(['domain' => '{subdomain}.{domain}'], function () {
    // your routes
});

Or just use {domain} without the subdomain altogether.

For more info on your second question (sharing credentials) you should look at "cross-origin cookies", you can find some information here Cross-Domain Cookies

inet123
  • 764
  • 6
  • 10
  • Hey, thank for that, so i just point my document root for each of the domains to the laravel /public/ directory and then group my routes by domain should work fine? I thought it was only for subdomains –  Aug 07 '18 at 23:06
  • Exactly, you can even do a wildcard in the nginx so you won't need to define every domain - find more info here https://serverfault.com/questions/527156/setting-nginx-to-catch-all-unhandled-vhosts – inet123 Aug 08 '18 at 18:39