6
# SET DISPLAY ORDER
IndexOrderDefault Descending Name

the above value is used to sort directory listing in decending name value how can i create the similiar results for sorting the directory in last modified order.i am using .htaccess.please don't show the alternative ways

# SET DISPLAY ORDER
IndexOrderDefault last modified 

specify the default directory display order:

here is what my .htaccess file look like

RewriteEngine On
RewriteBase /
 # Disable server signature
 ServerSignature Off
sukhjit dhot
  • 183
  • 1
  • 1
  • 4

1 Answers1

13

First of all: my pet peeve, quoted from from the manual on .htaccess files:

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

Second, more reading of the manual is also useful:

The IndexOrderDefault directive is used in combination with the FancyIndexing index option.

Translation: include the FancyIndexing option in the IndexOptions directive.
Then right below that in the manual:

IndexOrderDefault takes two arguments. The first must be either Ascending or Descending, indicating the direction of the sort. The second argument must be one of the keywords Name, Date, Size, or Description...

That results in the following:

<Directory /some/path>
   # Disable .htaccess files for performance:
   AllowOverride none

   # Enable automatic index generation for directories without a DirectoryIndex file 
   # and sort them by date:
   Options +Indexes 
   IndexOptions FancyIndexing
   IndexOrderDefault Descending Date
</Directory>
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • hello sir you say using htaccess may lead to slow page load but personally i haven't noticed any diff in load time before or after. – sukhjit dhot Nov 08 '14 at 15:27
  • 1
    When AllowOverride enables the use of .htaccess files, httpd will look in every directory for .htaccess files. Thus, permitting .htaccess files causes a performance hit, whether or not you actually even use them! Also, the .htaccess file is loaded **every time a document** is requested. Apache must look for .htaccess files in all higher-level directories, in order to have a full complement of directives that it must apply. If a file is requested out of a directory /www/htdocs/example, httpd must look for these too: /.htaccess /www/.htaccess /www/htdocs/.htaccess /www/htdocs/example/.htaccess – HBruijn Nov 08 '14 at 19:38