Mailing List Archive

Content negotiation based on date?
I'm in the process of setting up my Apache (1.3.19) to do content
negotiation. It works, but I've got a small problem that I would like some
help with... :-)

Let's say that I've got a dir named foo, containing three files named bar,
followed by a date in the form YYYYMMDD and then the extension. That is:

/foo/bar.20020126.html
/foo/bar.20020127.html
/foo/bar.20020128.html

If I then request just /foo/bar, I would like Apache to serve the document
with the newest date, in this case /foo/bar.20020128.html - only problem
is, it just serves the first document it encounters in the directory,
/foo/bar.20020126.html.

I've looked over everything I could find via Google on content negotiation
with no luck. Also, I have read Apaches documentation on URL Rewriting
(mod_rewrite), but I really don't understand regexps! :-(



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: Content negotiation based on date? [ In reply to ]
> From: Lars Rander [mailto:maillist@rander.dk]

> Let's say that I've got a dir named foo, containing three files
> named bar,
> followed by a date in the form YYYYMMDD and then the extension. That is:
>
> /foo/bar.20020126.html
> /foo/bar.20020127.html
> /foo/bar.20020128.html
>
> If I then request just /foo/bar, I would like Apache to serve the
> document
> with the newest date, in this case /foo/bar.20020128.html - only problem
> is, it just serves the first document it encounters in the directory,
> /foo/bar.20020126.html.
>
> I've looked over everything I could find via Google on content
> negotiation
> with no luck. Also, I have read Apaches documentation on URL Rewriting
> (mod_rewrite), but I really don't understand regexps! :-(

This can't be done in any standard way in Apache. You could probably coax
mod_rewrite into doing it with some kind of prg: magic, but I don't
recommend it. Instead, I would do one of the following:

- Write yourself a custom module (in C or perl/mod_perl) that does this.

- Modify your content creation system so that this sort of thing isn't
necessary. For example, make sure that the most recent file has a different
base name (or has a symlink from a different base name).

The second option is probably much easier.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Content negotiation based on date? [ In reply to ]
>> From: Lars Rander [mailto:maillist@rander.dk]

>> Let's say that I've got a dir named foo, containing three files
>> named bar,
>> followed by a date in the form YYYYMMDD and then the extension. That is:
>>
>> /foo/bar.20020126.html
>> /foo/bar.20020127.html
>> /foo/bar.20020128.html
>>
>> If I then request just /foo/bar, I would like Apache to serve the
>> document
>> with the newest date, in this case /foo/bar.20020128.html - only problem
>> is, it just serves the first document it encounters in the directory,
>> /foo/bar.20020126.html.

> - Modify your content creation system so that this sort of thing isn't
> necessary. For example, make sure that the most recent file has a different
> base name (or has a symlink from a different base name).

If you could make it DDMMYYYY, it would already be working.

---------------------------------
tomss@ids.net 401-861-2831
http://as220.org/~tomfool

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org