syahmiibrahim's avatar

[NEED HELP] Subdomain

Hi , Does anyone have try this in their project ? https://laravel.com/docs/5.4/routing#route-group-sub-domain-routing

Route groups may also be used to handle sub-domain routing. Sub-domains may be assigned route parameters just like route URIs, allowing you to capture a portion of the sub-domain for usage in your route or controller. The sub-domain may be specified by calling the the domain method before defining the group:

Route::domain('{account}.myapp.com')->group(function () { Route::get('user/{id}', function ($account, $id) { // }); });

could you guys share how to use this stuff .

I try to google but no answer

0 likes
4 replies
mikevrind's avatar

I used subdomains in multiple projects. It really works as simple as the documentation example states, I can only advice to read the documentation and implement the example (with your own domain obviously. What is your problem?

Don't forgot to register the subdomains somewhere to point to the same location as the regular domain so all subdomains are pointing to the same Laravel installation, this is a tiny but important detail.

1 like
AshboDev's avatar

@bashy perhaps this would be one you're able to help with. I can think of a certain website which used it ;)

1 like
bashy's avatar

@syahmiibrahim Depends what you need it for. If you just want it for aesthetics, you can just add a middleware to check the subdomain exists etc.

1 like
syahmiibrahim's avatar

Thanks all, I think I figured out how to use as documentation example .

Please or to participate in this conversation.