Skip to content
Advertisement

Laravel main domain routes works for subdomain

When I open test.example.com/main I expect a 404 error because this route is not defined in subdomain routes. but main domain routes works for subdomain. So route Route::get('/main' ... runs and looks valid while it must not be valid.

My routes/web.php :

JavaScript

Advertisement

Answer

i don’t have much experince with laravel, but i think the problem is that main route is begin set to match all domains while /sub route is inside the subdomain group, so i guess you have 2 options

1 – group each domain routes together :

JavaScript

2 – create a middleware domain to check the host and return 404 error if the host doesn’t match ( i guess the first option would be better )

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement