Problem in restricting access to subdomains in multi-site

Events happening in the community are now at Drupal community events on www.drupal.org.
nattyweb's picture

I've just made my first Multi-site go live, with the first now live. It's defined using a subdomain structure, like site1.example.com and this works fine.

The problem is, if I type into the browser address site2.example.com, or anything-at-all.example.com, it goes straight to the install.php for my first site - which of course it can't run as it's already built. I've clearly got something wrong here. What I'd really like to do is have access restricted, so that unless you type in an existing address, like my first example above, either (1) nothing happens but a default page, or redirect, or (2) the default site appears.

Any suggestions or pointers? I have spent AGES looking round the various sources for help but am just getting more confused!!!

I'm not expert with .htaccess - so if this is the route to happiness, I'll need a little hand-holding.

Thanks in advance!

Maranjo

Comments

You could hack the

mcp-gdo's picture

You could hack the installation files... Only let the user access the installation files if they are ADMIN.
But that would not be very elegant.

Marcel

http://www.TrinidadWebmaster.com - My webmaster services
http://www.Motorology.com - My group of business websites and services
http://www.TrinidadAndTobagoFootball.com - Trinidad and Tobago Football

No

agentrickard's picture

Don't hack anything.

It sounds like you either: a) have not created settings folder for all the subdomains; or b) your webserver is not configured to send all DNS requests to the same IP, where your settings reside.

--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3

What about htaccess?

nattyweb's picture

Thanks for the suggestions folks. Isn't there just something I need to do to the default.htaccess file? It seems strange that the normal behaviour is that anything.example.com will route through to the install script.

.htaccess

agentrickard's picture

You should not need to edit .htaccess.

What folders do you have in your /sites directory?

--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3

.htaccess and multi-site

nattyweb's picture

Hi Agent Rickard

I have:
/all
/default
/subdomain1.example.com
/subdomain2.example.com

..and that's the lot. Are you on to something here?

Possibly

agentrickard's picture

Is the settings file inside default configured?

I think that your DNS is pointing the records to the sites directory and then Drupal is not finding the proper settings directory.

Non-existent domains like anything.example.com should resolve to default right now. If that hasn't been configured, then it will prompt for the install sequence.

If you are using wildcard DNS, you probably need an example.com directory with the default settings for your main site.

--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3

You got it!

nattyweb's picture

You hit the nail on the head and I should have realised that. I have replaced the /default/settings.php - which was the fresh install version - with the settings.php file from the subdomain I wanted to be the default.

Many thanks!

Maranjo

http://www.natty.co.uk

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: