We all know that laravel
’s routing supports subdomain names. as follows
Route::group(array('domain' => '{account}.local.com'), function()
{
Route::get('user/{id}', function($account, $id)
{
//
});
});
But I now encounter a problem. The local development environment, test environment and online production environment are different subdomains.
For example:
Offline: account.local.com
Test:account.test.com
Generate: account.production.com
In addition to writing the routing rules three times, I accidentally. I wonder if there is a way to support these three subdomain names in one routing rule at the same time?
Route::group(array('domain' => '{account}.local.com'), function()
{
// route
});
Route::group(array('domain' => '{account}.test.com'), function()
{
// route
});
Route::group(array('domain' => '{account}.production.com'), function()
{
// route
});
-------------------------------Dividing line-------------- ----------------------------
The following is sufficient.
Route::group(array('domain' => 'account.{env}.com'), function()
{
// route
});
Because I have other domain names and don’t want to mix common route
, so I need to distinguish them
Route::group(array('domain' => 'help.{env}.com'), function()
{
// route
});
The routing configuration of the three environments does not need to be configured
domain
. As long as your three domain names point to Laravel, they will naturally be sharedIt is supported. Have you tested it yourself?
You can also make distinctions in the configuration file
.env