3

I have two small sites finished at front-end stage that are closely related. One is the product, one the brand. The two sites use the same css and js files and are mostly static pages in three languages. The clients (and me) would like to do this under one craft set up

What do i have to do to keep (without a redirect)

www.product.com     (with eg www.product.com/nl/product-news)
www.brand.com       (with eg www.brand.com/nl/brand-news)

with only one admin and one template and public directory?

2
  • Did you try any of the answers given? We're having this issue now, and would like to know if there's a good work-around for it.
    – peirix
    Jun 3 '16 at 11:14
  • in the end i worked with a basic php files that reads json for the content. cms, css, js and assets where centralised in one domain. Jun 3 '16 at 12:42
3

Multisite is coming to Craft 3, so this only applies to v2 See here


I don't think there is an integrated way to do this and it might be worth reading this post:

Are there any intentions to release multisite support for Craft?

..we're pretty against adding it to Craft... at least in the way EE did it, where everything is stored on a per-site basis.

That said, I guess you could do this with symbolic links if you wanted, this is untested but in theory it should/could work...

Say you have these folders on your website:

  • craftinstall
    • craft
    • public
  • product
  • brand

You could do ln -s /path/to/craftinstall/public /path/to/product/public and then repeat that for the brand, this will then mean both the public folders for your websites will point to the craftinstall/public folder and should then be able to pick up the craft folder.

In your general.php config file you could have these settings:

 // Fetch url scheme
define('URI_SCHEME', ( isset($_SERVER['HTTPS'] ) ) ? "https://" : "http://" );

// Fetch current environment url
define('SITE_URL', URI_SCHEME . $_SERVER['SERVER_NAME'] . '/');


define('BASEPATH', realpath(CRAFT_BASE_PATH . '/../') . '/');

return array(

  // These are common (default) to all
 '*' => array(
   'environmentVariables' => array(
      'basePath' => BASEPATH,
      'siteUrl'  => SITE_URL
   )
 );

This would mean that whatever the url is, i.e: www.brand.com will be set as the siteUrl so in your actual craft install, under general settings your site url will simply be {siteUrl} and this will get replaced (same with basePath)

Which would then mean both sites should then point to the same craft install, now for templates and routes, this might not work, but it might but you could do something like this:

Your templates folder structure:

  • templates
    • brand.com
      • brand-news
    • product.com
      • product-news

And in public/index.php file something like:

define('CRAFT_TEMPLATES_PATH', "craft/templates/" . $_SERVER['SERVER_NAME']);

As I said, I haven't tried or tested this so it would be interesting if it did work, this is just my theory :)

2
  • ok, i'll try it out and let you know. thanks a lot alec! Feb 19 '16 at 10:07
  • This now changes with Craft 3. Perhaps you'd consider updating your answer?
    – Simon East
    Jun 15 '17 at 3:28
2

Completely untested, but you may consider setting up each site as environment using Multi-Environment Config approach.

Then in each domain's site root directory you'll need to place .htaccess and index.php like this is done for Localized Sites

Then you can configure URLs for each site pages in routes.php config file (so you can use different templates for different sites).

This is of course not as flexible as MSM in EE, but you'll have the 2 sites in one control panel and save on license cost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.