1
votes

I'm setting up access to a Drupal 7 site. The site sits alone on a box that answers to a number of domains and that number is likely to grow. What I'd like to do is to tell Drupal to load the site regardless of which actual domain brought us to the box (the rest of the URL will always be the same, of course). Currently most of those domains send me to the install page.

The problem is the lack of a directory (symlink) in the sites/ directory.

I can probably rewrite requests coming through alternate domains in Nginx, but I'm wondering whether there's an application level answer. As it stands right now, accessing the box/site by any domain other than the canonical domain sends me to the install page.

Is there anything I can do?

1
Sounds like a multi-site setup, is that true? If so you can edit sites/sites.php to map any number of domains to a single Drupal install. If this isn't a multi-site setup, and your site-specific stuff is all in sites/all, then you shouldn't have to do anything (setting server names/aliases and the root in nginx will be sufficient). Drupal doesn't natively do anything with the incoming domain name unless there's a multi-site setupClive
This is one site answering to many domains. The "stuff" is in a specific sites directory that isn't sites/all. I need any request answered by the box to know to look in our directory. Is there any way to use a wildcard? Maybe something like this: $sites['*'] = 'mycanonicaldomain.com'?Rob Wilkerson
Hmm...well, sites.php is a PHP file that gets interpreted like any other - why not test the currently requested domain in there, and dynamically build the $sites array based on that? If that doesn't work, you'll probably need to patch conf_path to let it know about the wildcard char (definitely doable though)Clive
Okay. I didn't know if a wildcard existed, but got left out of the documentation (just a pipe dream). Either way, thanks for the pointer. Would you add the content of your comment as an answer so I can mark it?Rob Wilkerson

1 Answers

0
votes

It looks to me that you didn't configure your Drupal site as the "default" one. The file "sites/default/settings.php" is loaded if no better (more specific to the current request) settings file can be found in the sites/folder... This is in fact a "wildcard" config, so the best solution would be to move the site files to the default folder. See the multi-site documentation for more details.

If you can't do that, then you can use sites.php for the rewriting, but you will need to update it to add any new URL you want to match. There's a little shortcut though: you can add a bunch of rewrites such as

$sites['com'] = 'default';
$sites['net'] = 'default';
$sites['org'] = 'default';
...

which will act as catch-all rewrites for sites ending in .com, .net, .org and so on, saving you a lot of (but not all) the manual rewrites.

Altering the conf_path() function should really be your last solution, since it will make updating Drupal a slower process (and if you forget to re-apply the changes after an update, your setup won't work any more).