[英]Laravel 4 - How to route subdomain to controller
I have a code work with laravel and Wildcard Domain. 我有一个与laravel和Wildcard Domain一起工作的代码。 I like to using Subdomain Route for a controller and I have a route like this:
我喜欢将Subdomain Route用作控制器,并且有这样的路由:
# 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
谢谢
Parameters in the domain like {parameter}.exam...
will be merged with the ones from the route. {parameter}.exam...
等域中的{parameter}.exam...
将与路径中的{parameter}.exam...
合并。 This causes a naming conflict {parameter}
and {parameter}
. 这导致命名冲突
{parameter}
和{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. 请注意,传递给
Modules()
的第一个参数将是子域,第二个是实际的路由参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.