shadowmoses Posted March 8 Posted March 8 (edited) Hi, I'm trying to serve a different templates folder depending on the domain name. For example sub.domain.com would load a use a templates-dev folder. I have got this working with the following code which I found on these forums: // Map domains to template folders $config->templates = [ $production_url => 'templates', // Production templates $sub_url => 'templates-dev', // Sub templates ]; // Set template paths dynamically based on HTTP_HOST if (isset($_SERVER['HTTP_HOST']) && isset($config->templates[$_SERVER['HTTP_HOST']])) { $folder = $config->templates[$_SERVER['HTTP_HOST']]; $config->urls->templates = "/site/$folder/"; $config->paths->templates = dirname(__DIR__) . $config->urls->templates; } I've also added the sub domain in the allowed hosts in the config, as follows: $config->httpHosts = array('www.domain.com', 'sub.domain.com'); This seems to work fine, apart from one slight issue... The home page is blank, but returns a 200 status code. All other pages work fine. I just can't work out why this is happening. There are no errors in the logs or anything. Nothing to indicate a problem. I'm stumped to why this is happening. Is there a better way to do this? Thanks in advance. Edited March 8 by shadowmoses
wbmnfktr Posted March 8 Posted March 8 First idea... is there an actual homepage template in all folders? Does your logic always return the correct strings on the homepage and other pages?
shadowmoses Posted March 8 Author Posted March 8 Yes the folders are currently identical, templates-dev is an exact clone of templates (which is working just fine). I'm puzzled why its not working...
shadowmoses Posted March 8 Author Posted March 8 I've decided to just create a custom module for this functionailty, still have no idea what the white page is all about though. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now