Skip to content

Instantly share code, notes, and snippets.

@melloc01
Last active August 29, 2015 14:06
Show Gist options
  • Save melloc01/50a1848f338f073181da to your computer and use it in GitHub Desktop.
Save melloc01/50a1848f338f073181da to your computer and use it in GitHub Desktop.
Routing VirtualHosts on Laravel 4
/*
|--------------------------------------------------------------------------
| Routing for VirtualHosts
|--------------------------------------------------------------------------
|
| If the App receives the request
| module.laravel.com
| It is translated to
| laravel.com/module
|
| Works perfectly with laravel-modules
| https://github.com/pingpong-labs/modules
|
*/
//your real host name
$host_name = 'laravel-lab';
//your virtual hosts that will be translated to '$host_name/$virtual_host'
$virtual_hosts = array ( 'vestibular');
if ( isset($_SERVER['HTTP_HOST']) )
{
$aux = explode(".{$host_name}", $_SERVER['HTTP_HOST']);
if (in_array($aux[0], $virtual_hosts))
{
$_SERVER['HTTP_HOST'] = 'laravel-lab';
if (sizeof($aux) > 1 )
{
$_SERVER['REQUEST_URI'] = "{$aux[0]}".$_SERVER['REQUEST_URI'];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment