AutoIndex Functionality

From Campus Web Server Help

Jump to: navigation, search

You might expect to browse to the images folder and see all the images in it. This is called AutoIndexing, part of the "Indexes" option. There are three reasons this might not work:

  1. Directory Permissions are not set to 755
  2. Indexes are not in the list of Options
  3. mod_security default rule is in place

Yep. We left the mod_security rule in place. So, there's no way you're going to get standard auto-indexes on our server. Indexes are rarely desirable, and lead to unintended consequences more often than helping. Use this PHP script if you require a listing of your files. Put it in the directory which you want to auto-index and name it "index.php".

<?php
if ($handle = opendir('.')) {
  while (false !== ($file = readdir($handle)))
     {   
         if ($file != "." && $file != ".." && ! preg_match('/.php$/',$file))
         {
               $thelist .= "<a href=\"$file\">$file</a>
\n"; } } closedir($handle); } ?> <P>List of files:</p> <P><?=$thelist?></p>
Personal tools