Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I am trying to use Apache's Rewrite module to redirect users before Django catches the request. I tried the following to redirect a user from "test.php" to the "links" page

   WSGIDaemonProcess processes=1 threads=15 display-name=$

   DocumentRoot "/home/james/www"
   <Directory "/home/james/www">
   Options +FollowSymlinks
   RewriteEngine On
   RewriteRule ^test.php links [NC,R=301,L]

   Order allow,deny
   Allow from all 

   WSGIScriptAlias / "/home/james/www/app.wsgi"



This approach does not work (when navigating to it does not redirect me to the "links" page, which does exists).

Is there a way to implement a Rewrite with mod_wsgi?

share|improve this question

It should work if mod_rewrite rule is written properly and in the right context. It is probably failing for you because you are doing it inside the Directory context and have it setup wrong for that context.

Why not though use simpler RedirectPermanent directive:

RedirectPermanent /test.php


This should be outside of Directory context and at top level within VirtualHost.

share|improve this answer
Thank you. I do need the rewrite module since I have already have a file with rewrite that I want to use. How can I check the configuration issue and make sure the context is set up correctly? – James Dec 26 '11 at 8:11
I would start by reading the Apache httpd documentation and understanding the difference between using RewriteRule inside of a Directory block and outside. Learn how to use the RewriteLog directive to log what mod_rewrite is doing and understand why it isn't applying your rule correctly. – Graham Dumpleton Dec 26 '11 at 10:11

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.