On Wed, Mar 12, 2014 at 4:57 PM, Guy Tamir <guytam...@gmail.com> wrote:
> Hey all, > > I have a Django app that serves to multiple domains. > In the primary domain (lets call it primary.com) I have some page that > are server via the path - primary.com/a/<key> > I want users from another domain (lets call it secondary.com) to be able > to get to this path : primary.com/a/<key> by entering secondary.com/<key> > (Both domains have a CNAME record pointing to the same server) > > Is there a way to reconfigure the URLCONF for specific domains so that it > will automatically go to a different urls file? > There are at least two options. 1) Deploy two different sites from the same codebase, with different settings files. The ROOT_URLCONF is a just a setting; if you only have a small, fixed number of subdomains, you may find it easiest to deploy a single version of your codebase, and have a different settings file for each subdomain. You then set up your web server to catch each domain and use the right settings file for each domain. 2) You can modify the URLconf as part of a middleware. Under this approach, you write a custom middleware that handles the request, and sets `request.urlconf` depending on the value of request.domain. request.domain contains the full domain for the site; request.urlconf controls which URLConf is used to resolve routing requests once middleware request processing is completed, overriding ROOT_URLCONF. This is effectively the same thing that django-subdomains does, but gives you access to the full domain, not just a subdomain. Ideally (from the point of view of the wider community), you would fork django-subdomains and provide the extra functionality to allow for control over full domains - but that's probably a bigger piece of work. I hope that helps. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84_drtCvcvbqepo_B9Vsw2C-HbDTfpdCTqLfT3x8ku1x%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.