Angga Ari Wijaya Angga Ari Wijaya - 3 months ago 7
PHP Question

Managing subdomain as part of website

I want build a website with separating domain like this

www.schifoo.com for main website

help.schifoo.com for help menu

account.schifoo.com for logged user

admin.schifoo.com for admin

classroom.schifoo.com some classroom online

blog.schifoo.com for blog


my question is, do I need to copy each core of application into each subdomain folder? or I can share the module of my framework (laravel) for each subdomain, let's say admin user and student user share the same functionality, if there are changes of the featured then I have to change the both of program? or there is a way to mapping the route as if subdomain but inside the program is single application? I hope my question understandable.. thanks and before you vote me down please give me chance to refine my question (because my English so terrible).

Answer

As per the docs, you can achieve this with sub-domain routing.

You just need to set up a group for each sub-domain of your application.

E.g routes.php:

Route::group(array('domain' => 'help.schifoo.com'), function(){
    Route::get('/', 'HomeController@helpHome');
});

Route::group(array('domain' => 'account.schifoo.com'), function(){
    Route::get('/', 'HomeController@accountHome');
});

Route::group(array('domain' => 'admin.schifoo.com'), function(){
    Route::get('/', 'HomeController@adminHome');
});

This will allow you to keep all of your code inside one application, simplifying your code base and meaning you don't need to worry about session sharing between laravel applications etc.

Comments