Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 689
Baako Avatar asked Feb 02 '15 18:02

Baako


People also ask

How to add subdomain in Laravel?

Show activity on this post. $appRoutes = function() { Route::get('/',function(){ return view('welcome'); }); }; Route::group(['subdomain' => '{subdomain}. yoursitename.com'], $appRoutes ); Place this code in your route file.

What is subdomain routing in Laravel?

by laravelrecipies. Subdomain routing is the same as routing prefixing, but it's scoped by subdomain instead of route prefix. There are two primary uses for this. First, you may want to present different sections of the application (or entirely different applications) to different subdomains.


1 Answers

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'
    ));
});
like image 131
lukasgeiter Avatar answered Sep 22 '22 17:09

lukasgeiter