1

I have a code work with laravel and Wildcard Domain. I like to using Subdomain Route for a controller and I have a route like this:

# Tester. URI : www.example.com/tester/{any}
Route::get('/tester/{any}', 'tester@Modules');

then i want to using Subdomain routing, so I change the route code like this:

#Subdomain route. URL : qwerty.example.com, it same as www.example.com/tester/qwerty
Route::group(array('domain' => '{parameter}.example.com'), function()
{
    Route::any('/tester/{parameter}', 'tester@Modules');
}

But didn't work. Can someone help me to resolve this problem? Thank you

Fredy
  • 2,840
  • 6
  • 29
  • 40

1 Answers1

0

Parameters in the domain like {parameter}.exam... will be merged with the ones from the route. This causes a naming conflict {parameter} and {parameter}. You must name the parameters differently:

Route::group(array('domain' => '{subdomain}.example.com'), function()
{
    Route::any('/tester/{parameter}', 'tester@Modules');
}

Note that the first argument passed to Modules() will be the subdomain and the second the actual route parameter.

lukasgeiter
  • 147,337
  • 26
  • 332
  • 270