This is an old revision of the document!

How to Customize Auto Index Script

The LiteSpeed web server supports automatic directory indexing when an index file is not present in a directory. It uses an external script to generate the index page on the fly. This provides you with maximum flexibility when creating the look and feel of your auto index page. You can also customize your index page at a global level, or for each natively configured virtual host.

The default script paired with the installation package is a PHP script. However, you can create your own script using any language you like.

When you write your own script, just remember that the path to the directory you’re indexing is passed to the script in a CGI environment variable: “LS_AI_PATH”. In PHP, you can retrieve the value with the command $_SERVER[‘LS_AI_PATH’].

The script can be placed anywhere you like, but if you want to share it among all of your virtual hosts, just place it under the lsws/share/autoindex/ directory. A “General Context” GUI with the URI “/_autoindex/” and Location “$SERVER_ROOT/share/autoindex/” is automatically created by LSWS for every virtual host. The default PHP script, located at lsws/share /autoindex/default.php, has the same look and feel as Apache’s mod_autoindex.

  • To create your own Auto Index Page globally:
	Server -> General -> Index Files -> Auto Index : Set to “Yes”	
  • If you leave “Auto Index URI” blank, default script (lsws/share/autoindex/default.php) will be used.
  • To use your own script, for e.g. myindex.php, you can place it under the same directory: lsws/share/autoindex/myindex.php. Do not modify default.php directly, as it will be overridden after any upgrades. Your own script and configuration will not be affected by version upgrade.
	Server -> General -> Index Files -> Auto Index URI: Set to “/_autoindex/myindex.php”
  • To customize your Auto Index Page for a particular virtual host if it is natively configured:
	VHost -> General -> Index Files -> Auto Index : Set to “Yes”	
	VHost -> General -> Index Files -> Auto Index URI: Set to the URI of your script.
  • If Auto Index is enabled or when a directory with no index file is accessed, LiteSpeed Web server will perform an internal redirect to “Auto Index URI”. If the value is not set, the URI will contain the default value “/_autoindex/default.php”.

You cannot customize the index file at the virtual host level if the virtual host is configured through an Apache configuration file. In that case, you can only apply a customized index file at the global level.

  • Admin
  • Last modified: 2015/07/20 18:55
  • by Michael Alegre