Wildcard in route in Laravel

Solution 1:

the 'domain.com' in your code must be the same as your domain name

the main page route should be written after the Route::domain

so check your .env file and set the domain in APP_URL and try this :

Route::get('/firma/{slug}', 'CompanyController@company')->name('company');

Route::domain('{slug}.'. config("app.url"))->group(function () {
    Route::get('/', 'CompanyController@company')->name('company2');
});

// the main page route goes here
Route::get('/','MainController@main')->name("main");