1

How do subdomains work in relationship to multiple sites? This seems to be danced around in the documentation that is out there.

more specifically. If I have...

primarydomain.com as my site in the site folder.... and point the domain dev.primarydomain.com at the drupal install without a dev.primarydomain.com folder will dev load the primarydomain.com or the default site?

The key behind this is I am trying to setup a 3 tier environment for drupal (dev, test, prod) and want to have as few transformation processes to move things up the tier. So I am hoping I can simply put dev infront of the domain and everything will work.

Also if it does work can I do the same thing on a sub-subdomain? dev.blog.primarydomain.com?

Thank you for your help I am relatively new to drupal and working on putting an existing site into a dev environment to learn more safely.

1 Answer 1

1

Short answer is: if example.com exists in the sites folder and a settings.php file is inside it, that file will be selected to serve any request directed to *.example.com.

Long answer is: let's say an url such as "an.example.com/something" is requested and such request reaches Drupal, here is what happens:

  1. Does a settings file exist in a folder named an.example.com.something (inside the sites/ folder)?
  2. Does a settings file exist in a folder named example.com.something?
  3. Does a settings file exist in a folder named com.something?
  4. Does a settings file exist in a folder named an.example.com?
  5. Does a settings file exist in a folder named example.com?
  6. Does a settings file exist in a folder named com?
  7. Serve the default website.

If at any point of the process the answer to the question is yes, then that file is selected as the settings file. Of course it will work with more complex subdomains and also more complex paths, as well as port numbers. Have a look at the official Drupal documentation on multi-site and at the conf_path() function for more details.

1
  • Great Description of how this works. I thought something like this was the case but I wasn't sure and documentation seemed lacking. Commented Mar 6, 2014 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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