Forum

Django Rewrite Rules

C-S
28 March 2011, 17:10
Hi everybody,
Let me reopen the forum topic http://www.hiawatha-webserver.org/forum/topic/505

What happens with the rewrite rules described in the other forum topic is the following:

all links http://www.rrr.com/weblog/

become http://www.rrr.com/weblog/index.html/weblog/

My guess is that the rewrite rule is wrong and leads to StartFile being included in the links. After trying around without success, I ask Hugo and the community for help.

Django uses the following rewrite rules on Apache:

<VirtualHost 12.34.56.78>
ServerName example.com
DocumentRoot /home/user/public_html
Alias /media /home/user/python/django/contrib/admin/media
RewriteEngine On
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /mysite.fcgi/$1 [QSA,L]
</VirtualHost>
Hugo Leisink
29 March 2011, 01:00
The rewrite rule will be something like this:
Match ^/(media.*)$ Rewrite /$1
RequestURI isfile Return
Match ^/(.*)$ Rewrite /mysite.fcgi/$1


Don't forget to turn in the PathInfo feature:
VirtualHost {
...
EnablePathInfo = yes
}
C-S
30 March 2011, 00:40
Hi Hugo,
Thanks a lot for your hint. I am afraid, it did not work. It looks a bit like hiawatha tries to force the addition of the standard file index.html into the links, even if this file does not exist at all for django. So, for example, if I change StartFile to 'a', the links reduce to /weblog/a/weblog. Do you have any idea how I can tell Hiawatha that there is no such thing as a StartFile?
Hugo Leisink
30 March 2011, 10:12
I'm very sure that Hiawatha does not include the startfile in the URL. The only way the startfile is used is when a directory is requested. Hiawatha will then look for the startfile.

My guess is that due to some redirects by Django the startfile is included in the URL. Can you tell me the URL of your website so I can take a look at if redirecting is the cause?
This topic has been closed.