Support the ongoing development of →
Last updated 2 years ago.

I don’t think you can have ->name('basket'); twice.

You may have to write middleware that detects the domain Request::getHost(); <- if that still works

Last updated 5 years ago.

It works without any issue, as long as I manually go to the /basket address, so the router can handle it as it uses the correct route.

However it seems when using the named routes in a template or controller it just takes the first route with the correct name without looking to the domain.


Yeah that’s what I figured , you may not be able to use named routes in your project unless you names them name-1-aaa and name-1-bbb and do logic in blade to serve the proper link


Should this be reported as a bug on github or am I doing something completely out of scope here? It is unexpected behaviour to say the least.


Option 1: Don't use named routes in blade: use:

<a href="{{ url('/basket') }}">My Basket</a>  

instead of

<a href=" {{route('basket')}}">My Basket</a>  

this will use the current domain and link to the basket. Remove the ->name() attached to the route.

Option 2:

Route::get('/basket', function () {
	$domain = Request::getHost();
switch ($domain) {
    case 'domain-aaa':
          return redirect('yourview1');
    case 'domain-bbb':
          return redirect('yourview2');

return redirect()->action('HomeController@index');
    case 2:
          return redirect('404');


hope that helps, good luck :)

Last updated 5 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.