I appreciate your help.  In the mean time, I'll keep an eye out to see
if additional functionality is added to the File Exists rule.

Adam

On Mon, Jan 18, 2010 at 6:54 PM, Alejandro Barrera
<[email protected]> wrote:
> On Tuesday 19 January 2010 00:36:56 Adam Woodbeck wrote:
>> On Mon, Jan 18, 2010 at 5:58 PM, Alejandro Barrera
>>
>> <[email protected]> wrote:
>> > Hmm, it makes sense, you're doing a matching against anything ending in /
>> > but then when you do the substitution you use: ^/(.*)/$, that's what gets
>> > you the extra index.html.
>> >
>> > So, what exactly are you trying to do? Could you give me an example with
>> > the original url and what you want to get after the rewrite?
>>
>> Sure, but first a little background may be helpful.
>> Django-staticgenerator creates static files -- index.html files in
>> this case -- from dynamic content.  So the first time someone visits
>> http://domain.com/blog/, the request is passed onto django where
>> middleware creates the index.html file in the appropriate directory
>> structure.  Subsequent visits to http://domain.com/blog/ should serve
>> the static file instead of require django to generate the content
>> again.
>>
>> So what I'm trying to do is configure Cherokee to serve the static
>> file for a particular URL should it exist or pass the request onto
>> django in the event it doesn't exist.  Take http://domain.com/blog/
>> for example.  The corresponding static file would be
>> http://domain.com/blog/index.html.  So I'm trying to write a rewrite
>> rule to append "index.html" to the end of http://domain.com/blog/ and
>> use a File exists rule to serve up the static file if present. If
>> http://domain.com/blog/index.html doesn't exist, a second rewrite rule
>> would remove "index.html" from http://domain.com/blog/index.html and
>> pass the request on to the default rule (django).  I don't think
>> something like this is currently possible using just a File exists
>> rule similar to the Nginx example in my original email.
>>
>> So to summarize, before the rewrite, the request would be
>> http://domain.com/blog/.  Following the rewrite, the request would be
>> http://domain.com/blog/index.html.
>>
>
>
> Hmm, I'm not sure there is any way to do the File exists part of what you want
> to do, although I must say it would be nice to add it.
>
> As for the regex, you can try this:
>
> Add a regex rule:
>
> ^/([^.])+/$
>
> Then add a redirect handler and *only* add the sustitution field:
>
> /$1/index.html
>
> That should in theory do what you expect and build the index part. I guess you
> then would need to add another rule to check if it exists but afaik I don't
> think there is a way to check if it exists or redirect on a 404 or similar.
> I'm copying Alvaro on this email to see if he can confirm this.
>
> Alex
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to