Skip to content

Instantly share code, notes, and snippets.

@bwaidelich
Created October 17, 2011 08:50
Show Gist options
  • Save bwaidelich/1292223 to your computer and use it in GitHub Desktop.
Save bwaidelich/1292223 to your computer and use it in GitHub Desktop.
FLOW3: Redirect to action based on (sub)domain
<?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