Jump to content

serve different /site/templates/ based on domain?


Recommended Posts

Standard website lives at www.foobar.com and by default the template files are served up from /site/templates/

Can processwire be set up to serve requests from dev.foobar.com by pulling template files from another directory? /devsite/templates or /site/devtemplate/ ?

Link to comment
Share on other sites

Place the below in your /site/config.php

// Honour goes to Raymond Geerts for the idea !
$config->templates = array(
    'dev.foobar.com' => 'devtemplate', // domain => templates folder name

if (isset($_SERVER['HTTP_HOST']) && isset($config->templates[$_SERVER['HTTP_HOST']], $config->templates)) {
    foreach ($config->templates as $host => $folder) {
        if ($_SERVER['HTTP_HOST'] === $host) {
            // set new paths
            $config->urls->templates = "/site/" . $folder . "/";
            $config->paths->templates = dirname(__DIR__) . $config->urls->templates;
  • Like 7
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...