-2

I would like to create a site that has multiple subdomains, each subdomain is an integral independent Laravel application. There is only one folder for the site.

Demontration

www.example.com (the main website)
blog.example.com (An independent blog)
music.example.com (Application of Independent Music)

I try to do this

Route::group(['domain' => 'dcolsay.dev'], function () {
    Route::get('/', function () {
        return view('welcome');
    });
});
Route::group(['domain' => 'blog.dcoslay.dev'], function () {
    Route::get('/', function() {
        return view('blog::index');
    });
});

I use PingPong - Module https://github.com/pingpong-labs/modules

The first route work but the second i have this error

NotFoundHttpException in RouteCollection.php line 161:

Mike Barwick
  • 6,288
  • 6
  • 51
  • 76
  • ...and?? What code have you tried? Please share. – Mike Barwick Apr 26 '16 at 22:19
  • `Route::group(['domain' => 'dcolsay.dev'], function () { Route::get('/', function () { return view('welcome'); }); }); Route::group(['domain' => 'blog.dcoslay.com'], function () { Route::get('/', function() { return view('blog::index'); }); });` – Boris Dehoumon Apr 26 '16 at 22:35
  • ...and what's the problem? Explain the problem you're running into. And always include code to avoid getting down votes - but more importantly, find a solution to your problem. – Mike Barwick Apr 26 '16 at 22:39
  • What happens when you replace `return view('blog::index');` with `return "test";` and you then visit the URL? – Mike Barwick Apr 26 '16 at 23:43
  • are you using nginx? if yes then you need to configure it – Goper Leo Zosa Apr 27 '16 at 06:57

2 Answers2

1

If you want to use the index.php from the folder of resources > blog then you have to use the view as "return view('blog.index');" instead of "return view('blog::index');"

Arvind
  • 827
  • 2
  • 8
  • 17
0

I suggest you to use Hyn's package : https://github.com/hyn/multi-tenant

I used it for my server with one laravel application for all projects hosted. Every domain has it own diretory such as views, routes, translations, packages etc...

You also use https://github.com/hyn/management-interface to create dashboard to manage your hostnames.

trinvh
  • 1,500
  • 2
  • 11
  • 20
  • Please note that this answer is provided based on an older version of hyn/multi-tenant. The management interface has become deprecated and was removed. Please see https://laravel-tenancy.com for the latest information on this package. – Luceos Apr 16 '18 at 13:52