$url = parse_url($_SERVER['HTTP_HOST']);
$host = explode('.', $url['path']);
$subdomain = count($host) > 2
? implode('.', array_slice($host, 0, count($host)-2))
: "";
$_SESSION['subdomain'] = $subdomain;
switch ($subdomain)
{
case "www":
$app->get('/', function () use ($subdomain)
{
return "Woof-woof, buddy.";
});
break;
default:
$app->get('/', 'WelcomeController@index');
break;
}
Created
December 3, 2015 07:49
-
-
Save cjthomp/465607242780cc5af803 to your computer and use it in GitHub Desktop.
Laravel Lumen sub-domain routing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment