Is it possible for Drupal to handle both subdomain and subpath for a single site in a Drupal multi-site environment?

For example:

foo.example.com ---> 'foo'

example.com/foo ---> 'foo'

Is this possible? Would I run into any issues?

1 Answer 1


You can configure your desired structure/aliasing by creating the sites.php file in the sites directory. See the example.sites.php file in the same directory for extensive documentation on this topic.

So, for your use case:

$sites['foo.example.com'] = 'foo';
$sites['example.com.foo'] = 'foo';

When visiting foo.example.com or example.com/foo, Drupal will return the "website" located at sites/foo. (However, instead of foo usually the name of the (sub)direcotry is one of these aliases).

About running into any issues, the one thing that comes into my mind is that search engines seem to appreciate unique content. It is considered bad practice if your (public) content can be accessed by multiple web addresses (therefore generally it is recommended to set up 301 redirects, however, not sure if this is the right place to discuss this topic since it is not specific to Drupal).

  • This pretty much solved it, but I needed one more step. In order to get the subpath working (example.com/foo), I needed to add a symlink for 'foo' to point to itself in the Drupal docroot: ln -s . foo
    – HumanSky
    Aug 3, 2015 at 12:54

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.