Reputation: 326
I've got the following directory structure:
/ (index) /blog/ /about/
Running only one Django instance, I want the URL to display as blog.domain.com (for my blog app), but all the other URLs to run under (www.)domain.com/.
I could surely hardcode the links, forcing this setup (basically the webserver will listen to blog.domain.com and do a forward as domain.com/blog/ but the user will still see blog.domain.com) but I want to be able to resolve my URL-configs the proper way but still get them to point to domain.com or blog.domain.com depending on the url (app) being resolved.
Is there a good way of doing this? I was thinking of a custom templatetag to use instead of {% url my_resolve_name slug="test" as test %}
.
Upvotes: 3
Views: 2041
Reputation: 1010
try this on nginx:
server {
listen 80;
server_name www.example.com;
if ($host ~* "^blog\.example\.com") {
rewrite ^(.*)$ /blog$1 permanent;
break;
}
}
this rewrites all requests to blog.example.com/some/params/ to www.example.com/blog/some/params
Upvotes: 0
Reputation: 7758
There is no builtin support for it, but many people (including me) have done it in a hackish sort of way.
http://uswaretech.com/blog/2008/10/using-subdomains-with-django/
http://uswaretech.com/django-subdomains/
Upvotes: 1