On Monday 18 January 2010 19:57:46 Adam Woodbeck wrote:
> I'm currently running a Django app under Cherokee quite successfully.
> Now I'm trying to integrate django-staticgenerator
> (http://superjared.com/projects/static-generator/) into the site to
> generate static files from select pages.  Staticgenerator docs give an
> example of how to properly configure Nginx rewrite rules as follows:
> 
> location / {
>     if (-f $request_filename/index.html) {
>         rewrite (.*) $1/index.html break;
>     }
>     if (!-f $request_filename) {
>         proxy_pass http://django;
>         break;
>     }
> }
> 
> All Django URLs end with a "/" so the rewrite rules above look for the
> existence of "(.*)/index.html" file.  If found, the URL is rewritten
> to direct the client to the static index.html file.  If the file does
> not exist, the request is passed onto Django.  So here is what I've
> tried in Cherokee to emulate these Nginx rules.
> 
> My default rule sends requests to Django through FastCGI.  So to mimic
> the behavior of the rewrite rules above, I figure I need to:
> 1. create a Regular Expression rule looking for "^/(.*)/$" and
> redirect "^/(.*)/$" to "/$1/index.html" (Final is turned off)
> 2. create a File Exists rule for any and only files, using a Static
> content handler (Final is turned on)
> 3. create a Regular Expression rule looking for "^/(.*)/index.html$"
> and redirect "^/(.*)/index.html$" to "/$1/"  (Final is turned off) so
> the original request can be send to Django in the default rule
> 
> The above is not working for me since the resulting URL looks
> something like this,
> "http://domain.com/blog/index.html/index.html/index.html/index.html/index.h
> tml/index.html/index.html/" before the connection finally terminates due to
>  too many redirects.

I recently run into a similar problem, the redirection is due to an incorrect 
regex and the reevaluation of it, or putting it in another way, your 
redirected string matches your regex again ans gets redirected another time, 
and so on until it times out.

Try being more specific about your regex:

^/([^.]+)/index.html$

With this regex it will only evaluate everything except a dot (avoiding your 
nasty redirection).

Give it a try and let us know :)

Alex

> 
> Please excuse me as I'm not very experienced with regular expressions
> nor with Cherokee.  If the File exists rule would take regular
> expressions instead of or in addition to a list of files like the
> Nginx rules above, I may be able to do this all in one rule.
> 
> I've been at this all morning trying to get this working so any help
> you can offer, I would greatly appreciate it.
> 
> Sincerely,
> Adam
> _______________________________________________
> Cherokee mailing list
> [email protected]
> http://lists.octality.com/listinfo/cherokee
> 

-- 
http://www.neurosecurity.com

"We must be the change we wish to see in the world"
Mahatma Gandhi
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to