Skip to content

Instantly share code, notes, and snippets.

@Lotuashvili
Last active March 21, 2017 09:23
Show Gist options
  • Save Lotuashvili/27bc4e83529814fe1e07 to your computer and use it in GitHub Desktop.
Save Lotuashvili/27bc4e83529814fe1e07 to your computer and use it in GitHub Desktop.
Laravel subdomain routing
<?php
$host_array = array_reverse(explode('.', parse_url(url())['host']));
$domain = $host_array[1];
$tld = $host_array[0];
$host = $domain . '.' . $tld;
Route::group(['domain' => '{sub}.' . $host], function () {
get('/', function($sub) {
return 'Subdomain: ' . $sub;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment