Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im currently writing a django website, and ive got a bunch of flatpages that are my basic website. What i want is to be the main website flatpage, but when people go to it redirects to Im sure this is a simple thing, i just had trouble coming up with the correct search terms.

A few possible solutions that ive had a look into

  1. mod_rewrite for apache. Seems a little overkill for this.
  2. DNS redirect. once again seems ok if going from to but not for what I want.
  3. django.contrib.redirects, Seems will do what I want, but again seems like its for some other reason.
  4. Is there something I can do in my virtual hosts file?

Im running Ubuntu Server 9.04, apache 2.2 and Django 1.1 with wsgi.



share|improve this question
up vote 1 down vote accepted

mod_rewrite is a perfect fit for this:

RewriteEngine On
RewriteRule ^/$ /home/ [R]
share|improve this answer
Does the mod_rewite go in the virualhosts file? – Mark Feb 4 '10 at 8:41
yes. and now some more to fill the comment. – Christian Feb 4 '10 at 8:45
+1 for the good answer. But gave the actual answer because of performance reasons to Mathieu. – Mark Feb 4 '10 at 10:47
actually this worked first time. And i wasnt sure where to put the index.html considering the wsgi script. So I gave you the answer instead – Mark Feb 4 '10 at 11:01

you can also put a static index.html page with this html code in the head section of this nearly empty html page:

META HTTP-EQUIV="refresh" CONTENT="0;URL=/home">

You will need to add a "<" at the beginning of course, it's blocked if i put it here

share|improve this answer
How performant is this compared to mod_rewrite. I like the simplicity tho. – Mark Feb 4 '10 at 8:44
this is clearly what will consume the less resource. It involves the minimum: send static content to client. I think that mod_rewrite will send a 302 directly, so users won't really notice. With this static page, they will see a white page for a second or two – Mathieu Chateau Feb 4 '10 at 8:49
And also i guess if you host the static content on nginx or something it will be faster/ it will also be cached? – Mark Feb 4 '10 at 8:57
page can be cached, more over if you explicitely add the expire meta tag inside the page – Mathieu Chateau Feb 4 '10 at 10:44
Do you know if this would work with wsgi? because I dont really know where the index.html would go in this case? – Mark Feb 4 '10 at 10:51

See my answer on Stack Overflow about how to do redirects in Django directly in

share|improve this answer
Any Idea on how performant this is compared to the other answers? – Mark Feb 4 '10 at 8:44
@Mark: No, sorry. – Teddy Feb 5 '10 at 7:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.