Skip to content

Instantly share code, notes, and snippets.

@cjthomp
Created December 3, 2015 07:49
Show Gist options
  • Save cjthomp/465607242780cc5af803 to your computer and use it in GitHub Desktop.
Save cjthomp/465607242780cc5af803 to your computer and use it in GitHub Desktop.
Laravel Lumen sub-domain routing
$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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment