如何使用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屋!
查看全文