I have this route in my web.php:
Route::get('/firma/{slug}', 'CompanyController@company')->name('company');
Route::domain('{slug}.domain.com')->group(function () {
Route::get('/', 'CompanyController@company')->name('company2');
});
And URL: domain.com/firma/firma-2 and firma-2.domain.com - this it the same page :) firma-2 - it's slug (or subdomain). domain.com - this is my main domain :)
Now, when I open: domain.com/firma/firma-2 - I see company view. It's okey. When I open: firma-2.domain.com - Iahve mainpage (main page = domain.com).
I need add to to this route wildcard:
company-name.name.com
How can I make it in Laravel?
CodePudding user response:
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");
