Last active
March 21, 2017 09:23
-
-
Save Lotuashvili/27bc4e83529814fe1e07 to your computer and use it in GitHub Desktop.
Laravel subdomain routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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