Routing to subdomain does not work laravel 8

  apache, laravel, php, routes, subdomain

When switching to a subdomain page endless load nothing happens, no errors.

My httpd.conf

<VirtualHost *:8000>
    ServerName example.com
    ServerAlias *.example.com
    DocumentRoot "/var/www/html/blog/public"
</VirtualHost>

hosts file

127.0.0.1   localhost
127.0.1.2   example.com
127.0.1.2   *.example.com

Routes

Route::get('/', function () {
  #dd(request()->cookie());
  return view('home.home');
})->name('home');

Route::domain('{username}.'.env('SESSION_DOMAIN'))->group(function () {
  Route::get('/', [PostController::class,'getAllPosts'])
  ->name('blog');
});

in .env

SESSION_DOMAIN=example.com

I do not understand what is wrong, please help me.

Source: Laravel

Leave a Reply