Search code examples
phplaravellaravel-4laravel-routing

How to create a sub- domain in laravel


I am trying to create a sub-domain in laravel. The subdomain will be something like merchant.example.com and they will be more links such as merchant.example.com/login merchant.example.com/myaccount so this is what I tired

Route::get('.partner/', array(
'as' => 'partner-home',
'uses' => 'HomeController@partnerHome'
));

but just redirect me to the main domain. Any idea how to this please.


Solution

  • You can register a route group to have a certain domain:

    Route::group(array('domain' => 'partner.myapp.com'), function(){
        Route::get('/', array(
            'as' => 'partner-home',
            'uses' => 'HomeController@partnerHome'
        ));
    });