laravel子域路由功能如何使用 [英] how to use the laravel subdomain routing function
本文介绍了laravel子域路由功能如何使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用来自 laravel 4 站点的以下代码
I am using the following code its from the laravel 4 site
Route::group(array('domain' => '{account}.myapp.com'), function() {
Route::get('user/{id}', function($account, $id) {
// ...
return Redirect::to('https://www.myapp.com'.'/'.$account);
});
});
这个想法是将 subdomain.myapp.com 重定向到 myapp.com/user/subdomain.我所拥有的没有任何建议?对不起,我刚开始使用 laravel 大约一个月了.
the idea is to redirect subdomain.myapp.com to myapp.com/user/subdomain .what I have is not working any suggestions?sorry I just started with laravel about a month now.
推荐答案
去掉 user/{id}
换成 /
然后使用下面的url https://accountname.myapp.com
,它将重定向到 https://www.myapp.com/accountname
Remove user/{id}
and replace it with /
and then use the following url https://accountname.myapp.com
and it will redirect to https://www.myapp.com/accountname
Route::group(array('domain' => '{account}.myapp.com'), function() {
Route::get('/', function($account, $id) {
// ...
return Redirect::to('https://www.myapp.com'.'/'.$account);
});
});
修改答案为正确答案
这篇关于laravel子域路由功能如何使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文