Vishal
Vishal

Reputation: 2346

django multi-tenancy and wildcard subdomains

I want to offer client.domain.com for every client on the site. In practice, client.domain.com is equivalent to www.domain.com/client/ (which I know how to handle in urls but isn't what I want).

  1. Can I use django-subdomains to allow this sort of wildcarding without defining SUBDOMAIN_URLCONFS since I don't want to try and enumerate for all clients.

  2. I'm currently using Apache. I don't want to create a new virtual host for each client as well. Is there a generic way to make client.mydomain.com work?

Appreciate all pointers to executing #1 and #2. Thanks.

Upvotes: 1

Views: 607

Answers (1)

Daniel Hepper
Daniel Hepper

Reputation: 29967

  1. You don't have to enumerate all clients, according to the example configuration in the docs, django-subdomains will use the ROOT_URLCONF when no entry in SUBDOMAIN_URLCONFS matches.

  2. I'm not very familiar with Apache, but you should be able to use a wildcard ServerAlias:

    <VirtualHost *:80>
        ServerName www.example.com
        ServerAlias *.example.com
        ...
    </VirtualHost>
    

Upvotes: 1

Related Questions