Last active
August 29, 2015 14:06
-
-
Save melloc01/50a1848f338f073181da to your computer and use it in GitHub Desktop.
Routing VirtualHosts on Laravel 4
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
/* | |
|-------------------------------------------------------------------------- | |
| 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