简体   繁体   English

laravel 5.5-打破子域模式

[英]laravel 5.5 - breaking subdomain pattern

I implement a subdomain system for user, which every user can go to their profile page like user.example.com . 我为用户实现了一个子域系统,每个用户都可以像user.example.com一样user.example.com其个人资料页面。

Route::domain('{subdomain}.example.com')->group(function () { 
    Route::get('/', 'ProfilesController@subDomain'); 
    });

Which ProfilesController@subDomain is a function that retrieve the data and redirect the page. 其中, ProfilesController@subDomain是用于检索数据并重定向页面的函数。 However, user will always stuck in that url pattern no matter where he go. 但是,无论用户身在何处,都会始终停留在该网址格式中。

For example, if abc.example.com , I want it to redirect to example.com/profiles/abc . 例如,如果是abc.example.com ,我希望它重定向到example.com/profiles/abc But now I get abc.example.com/profiles/abc . 但是现在我得到了abc.example.com/profiles/abc And any link I go, it will stuck with abc.example.com . 我所走的任何链接都将停留在abc.example.com

How can I break that pattern after loading the profile page? 加载个人资料页面后如何打破该模式?

Normally you would do something like this with 通常,您可以使用

Route::group(['domain' => '{domain}'], function() { });

This would allow you to route to the domain of choice. 这将允许您路由到选择的域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM