Created
October 17, 2011 08:50
-
-
Save bwaidelich/1292223 to your computer and use it in GitHub Desktop.
FLOW3: Redirect to action based on (sub)domain
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 | |
abstract class AbstractBaseController extends ActionController { | |
/** | |
* Redirect to specific controller if current subdomain is not equal to the current controller name | |
* Note: initializeAction() is called before every action by default | |
* | |
* @return void | |
*/ | |
protected function initializeAction() { | |
$domainParts = explode('.', $this->environment->getHTTPHost()); | |
if (count($domainParts) < 2) { | |
return; | |
} | |
$subDomainName = $domainParts[0]; | |
if (strtolower($subDomainName) === strtolower($this->request->getControllerName())) { | |
return; | |
} | |
$this->forward('index', $subDomainName); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment