The goal is to have single site (subdomain.domain.dev) with single locale(en_gb) in it and with one craft installation shared with this site only.

I'm not sure if I configured general.php and db.php correctly to get subdomain.domain.dev loaded.

Production steps of What I did:

  1. Set up host to point to subdomain - subdomain.craft.dev

    Folders structure:




  2. Created database - subdomain_dev

  3. Uploaded necessary files to subdomain folder and edited one line of code

    // Tell Craft to serve the subdomain content define('CRAFT_LOCALE', 'subdomain');

  4. Uploaded en_gb templates to ../craft/templates/en_gb.

    I'm not sure, If I also should edit $craftPath to point to templates files for en_gb locale.

  5. Edited general.php

    // All environments
    '*' => array(),
    // Development environment - Locale
    'craft.dev' => array( 
        'devMode' => true,
        'siteUrl' => array(
            'en' => 'http://craft.dev',
            'en_gb' => 'http://subdomain.craft.dev'

  6. Edited db.php

    // All environments
    '*' => array(
        'tablePrefix' => 'craft',
    // Development environment - Locale
    'craft.dev' => array(
        'server' => 'localhost',
        'user' => 'root',
        'password' => '********',
        'database' => 'craft_dev',
    // Development environment - Locale
    'subdomain.craft.dev' => array(
        'server' => 'localhost',
        'user' => 'root',
        'password' => '********',
        'database' => 'subdomain_dev',

Locale en_gb was also created from back-end. When I load the http://subdomain.craft.dev, I get Twig_Error_Runtime saying, that variable doesn't exist.It's like templates in ../craft/templates/en_gb wasn't found?

  • What are you trying to accomplish? Are you trying to create a single site with more than one locale (with shared templates and resources)? Or create entirely separate sites for each locale (nothing shared)? Apr 25, 2015 at 16:05
  • The goal is to have separated sites for each locales by sharing the same domain. If I understand the licensing right, so I wouldn't have to buy licenses for each locale separately. Apr 25, 2015 at 16:10
  • As far as I know you should not have to buy separate licenses. My understanding is that you can install as many version of craft as you want on the same domain (subdomains don't count). But might check with P&T to confirm. Apr 25, 2015 at 16:12
  • When you buy your license for domain.com, you should be able to copy the license file over to the subdomain.domain.com install. Apr 25, 2015 at 16:16
  • 1
    Yes. I've asked this before for my own server, as I often host development staging sites for my clients before I get a chance to set up their servers. (I.e. 'clientA.mycompany.com' and 'clientB.mycompany.com'; both of which use the license for 'mycompany.com'). Apr 25, 2015 at 16:33

1 Answer 1


Generally speaking, locales are designed to share the same templates, so craft is not necessarily looking for a /template/[locale]/ folder to find the correct templates to load. You may have to specify the different locale template paths as part of your section settings in that locales database. As far as I know the only automatic locale routing happens in your public folder, if craft is trying to resolve a route for a static page.

I'm curious as to why you would want to point the different locales to different databases? Keep in mind that structure and data are both stored in the craft database, so if you point 'locale1' at 'db1', and 'locale2' at 'db2', you are essentially loading two entirely separate sites (with their own CP, users, sections, fields, etc). This might make sense if you want to share templates and resources between the two sites. However, if you are also not sharing templates, then it might make more sense to just create two separate installations of craft.


Regarding licensing and subdomains. My understanding is that you can use the same craft license on more than one craft install as long as they share the same primary domain (subdomains are ok). In your case you would set up your local dev environment to be something like: 'project.craft.dev' and 'localeA.project.craft.dev'; and the production environment to be 'domain.com' and 'localeA.domain.com'. You can then purchase the license on 'domain.com' and copy the license file (craft/config/license.key) over to 'localeA.domain.com'.

This is presuming of course that they share the same primary domain. What you can NOT do is create 'domain-localeA.com' and 'domain-localeB.com' using the same license.

  • I uploaded only files that will be overwritten. The idea behind all that is that I wanted to avoid of loading others sites(as you said CP, sections, fields ...etc), when It's not necessary, you know... to save nature and my economy :) I would do it in domain way for each locale, but It would be too expensive. Apr 25, 2015 at 16:37
  • So the separate installation (as you mentioned in second paragraph) for each locale is the way for subdomain.domain.com with no need to buy extra licenses for each subdomain. Apr 25, 2015 at 16:42
  • That's my understanding—Yes. Apr 25, 2015 at 16:55

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.