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
});
曾经蜡笔没有小新2017-05-16 16:54:09
The routing configuration of the three environments does not need to be configureddomain
. As long as your three domain names point to Laravel, they will naturally be shared
迷茫2017-05-16 16:54:09
You can also make distinctions in the configuration file
Route::group(array('domain' => env('DOMAIN')), function()
{
// route
});
.env
DOMAIN=xxx.xxx.com