Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lightstyle's avatar

How to set correct route for subdomain homepage?

I created a subdomain named "account" and tried to set root view for subdomain, but I see only website root view, my root is:

Route::get('/', function () {
    return view('welcome');
})->name('websitehome');

Route::group(['domain' => '{account}.maindomain.dev'], function () {
    Route::get('/', function () {
        return view('accountindex');
    })->name('accountindex');
});

I want to see "accountindex" and not "websitehome" on account.maindomain.dev, possible?

0 likes
1 reply
lightstyle's avatar
lightstyle
OP
Best Answer
Level 1

Solved, I created also a route group for main domain:

Route::group(['domain' => 'maindomain.dev'], function () {
    Route::get('/', function () {
        return view('welcome');
    })->name('websitehome');
});

Hope this is correct...

1 like

Please or to participate in this conversation.