Answer the question
In order to leave comments, you need to log in
How to solve the problem with the naming of routes in the presence of subdomains?
There is a project for which regional pages should be implemented, then each city has its own subdomain {city}.site.ru
. I added to RouteServiceProvider.php the connection of the file with routes twice, for the main domain and subdomains:
Route::domain(env('APP_DOMAIN_URL'))
->middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Route::domain('{city}.' . env('APP_DOMAIN_URL'))
->middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Route::view('/policy', 'web.sections.static.policy')->name('policy');
Answer the question
In order to leave comments, you need to log in
Don't double enter routes. This is fundamentally wrong. Possible options in your case:
1. Analyze the domain at the middleware level, and skip subdomains, if there are any in the request. And then steer the logic. Remove the division into subdomains and the base one from the routes.
2. Find out what Tenant is https://tenancyforlaravel.com/
3. Make prefixes in routes (which is not comme il faut in your case)
3 Think again about the logic of the pages, perhaps you don’t need named routes there.
Well, if you are friends with English: "Dynamic custom domain routing in Laravel" Google to help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question