Search code examples
laravelrouteslaravel-valet

Laravel 5.7 Routing not Working for Subdomain


For my Laravel application, I want to use subdomains to link to different spas with Vue.js. The only thing I have to do is link in the web.php to the Laravel Blade file but for some reason, it's not working.

<?php

Route::domain('test.mysite.test')->group(function () { 
    return view('test'); 
});

I run Laravel Valet for my virtual host. Does anyone have an idea what the problem could be?


Solution

  • Edit your code like this:

    Route::domain('test.mysite.test')->group(function () {
      Route::get('/', function () {
        return view('test');
      });
    });
    

    and be sure that you registered your subdomain virtual host too