I am working on creating a website in Django which consists of two parts: the website itself, and the forum. They will both be on separate domains, i.e. example.com and exampleforum.com. How can this be done in Django, when the forum and main site are part of the same instance?
+4
A:
This is done at the web server level. Django doesn't care about the domain on the incoming request.
If you are using Apache just put multiple ServerAlias directives inside your virtual host like this:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
ServerAlias forum.mydomain.com
... other directives as needed ...
</VirtualHost>
This tells Apache to direct requests for all of those domains into the same instance.
For nginx your config file would look something like:
server {
listen 80;
server_name www.mydomain.com mydomain.com forum.mydomain.com;
... other directives as needed ...
}
Van Gale
2009-04-05 22:35:38
Thank you for letting me know that I don't need to find an 'official' Django way of going about domain aliases.
Jonathan Prior
2009-04-05 22:51:20