[RFC] [PATCH] Autoindex: support sorting using URL parameters

Valentin V. Bartenev vbart at nginx.com
Wed Jan 30 18:54:29 UTC 2013

On Tuesday 29 January 2013 21:49:46 Peter Wu wrote:
> Based on Apache HTTPD autoindex docs[1]. Supported:
> - C=N sorts the directory by file name
> - C=M sorts the directory by last-modified date, then file name
> - C=S sorts the directory by size, then file name
> - O=A sorts the listing in Ascending Order
> - O=D sorts the listing in Descending Order
> Not supported (does not make sense for nginx):
> - C=D sorts the directory by description, then file name
> - All F= (FancyIndex) related arguments
> - Version sorting for file names (V=)
> - Pattern filter (P=)
> Argument processing stops when the query string does not exactly match the
> options allowed by nginx, invalid values (like "C=m", "C=x" or "C=foo") are
> ignored and cause further processing to stop.
> C and O are the most useful options and can commonly be found in my old
> Apache logs (also outputted in header links). This patch is made for these
> cases, not for some exotic use of Apache-specific properties.
>  [1]: http://httpd.apache.org/docs/2.4/mod/mod_autoindex.html

Personally I do not like these Apache hard-coded arguments.

I would prefer something like "autoindex_sort" directive

  autoindex_sort /criterion/ [ /order/ ];

with variables support.

And if user want Apache-like behavior then he will be able to configure
it like this:

  map $arg_C   $criteria {
      default  name;
      M        modified;
      S        size;

  map $arg_O   $ord {
      default  asc;
      D        desc;

  autoindex_sort $criteria $ord;

 wbr, Valentin V. Bartenev

More information about the nginx-devel mailing list