Re: Fwd: Different subdomain for each application (again)
Hi Tom. On Mar 24, 2:42 pm, Tom Smith <[EMAIL PROTECTED]> wrote: > A while ago Doug and Eivind asked about using subdomains for each app. > > I'd like to do this, but in the example they had a stab at they were > using Apache whereas I'm using Lighttpd... One thing you might like to consider is having Lighty map the subdomain in to the url where it can be matched against your urlpatterns. In the Lighty config you can use a regex to match the host. If the regex has captures, these are available to be passed to FastCGI using %1, %2, etc (captures in the rewrite rule are $1, $2, etc). So in the Lighty config you can use something like: $HTTP["host"] =~ "([\w\d-]+)?\.?example\.com" { ... snip ... url.rewrite-once = ( ... snip ... "^(/.*)$" => "/extraset.fcgi/%1$1", ) } Now if you go to blog.example.com, the URL Django gets is /blog. If you go to blog.example.com/2006/, Django gets /blog/2006/. This makes it easy to match the subdomain in urlpatterns: urlpatterns = patterns('', (r'^blog/$', include('project.blog.urls'), ... etc The blog app doesn't know anything about the prefix in the url and doesn't need to know it is running on a subdomain. The user never sees the /blog prefix because this happens within the webserver. I've had this working, so let me know if you need any more details. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Fwd: Different subdomain for each application (again)
A while ago Doug and Eivind asked about using subdomains for each app. I'd like to do this, but in the example they had a stab at they were using Apache whereas I'm using Lighttpd... ideally I'd like subdomainone.wherever.com and subdomaintwo.wherever.com to pass through without anything AFTER the /. I tried creating a root urls.py like this... urlpatterns = patterns('', (r'^/?$', 'app.views.main'), (r'^admin/', include('django.contrib.admin.urls')),) and a kinda main views.py like this... def main(request): #handle any calls from django.conf.urls.defaults import * server_name = request.META['SERVER_NAME'].split(".") domain = server_name[0] if domain == 'subdomainone': urlpatterns = patterns('', (r'^/?$', include('seo.one.urls')), ) if domain == 'subdomaintwo': urlpatterns = patterns('', (r'^/?$', include('seo.two.urls')), ) . of course I can get the domain out of the SERVER_NAME, but then setting urlpatterns doesn't actually DO anything does it? regards tom Tom Smith http://www.theotherblog.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 --- usability, findability, profitability, remarkability --- Tom Smith http://www.everythingability.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 --- usability, findability, profitability, remarkability --- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---