I'm looking to change the homepage of my app based on the domain name.
- Domain name x.com (our main app domain) to link to: controller: pages | action: home
- Domain name y.com or z.com (stores created via our main app domain) to link to: controller: stores | action: index
To set the homepage this route is defined:
Router::connect('/', array('controller' => 'pages', 'action' => 'home'));
Question: How do I make this dynamic and add conditions so that a different controller/action is loaded based on the domain name?
Notes:
- In AppController's beforeFilter I perform some database checks. It checks to make sure that the store does exist (via Store model). If the store/domain doesn't exist it redirects to our main domain name.
- I want to keep the URL clean. I don't want to redirect to pages based on the domain name. Redirecting would mean the homepages would look like like http://x.com/pages/home/ simply like http://x.com/