Wondering how to enable auto index in openlitespeed ? Our in-house experts are here to help you out with this article. Our litespeed support is here to offer a lending hand with your queries and issues.
How to enable auto index in openlitespeed?
Today, let us see the steps followed by support techs to enable autoindex in openlitespeed
By default, OpenLiteSpeed will have the Auto Index function disabled.
Auto Index can enable at the server level, vhost level & context level, and each sub-level will override a parent-level setting.
Enable/Disable Auto Index at the Server Level:
Server Configuration > General > Index Files
Index Files: The default values are
index.html
Copy Code
and index.php
Copy Code
separated by ,
Copy Code
Auto Index: Set to
Yes
Copy Code
to enable Auto Index, and set to No
Copy Code
or Not Set
Copy Code
to disable Auto Index.
Auto Index URI: The script to generate the index, by default (when empty) will use
/usr/local/lsws/share/autoindex/default.php
Copy Code
Enable/Disable Auto Index at the Vhost Level
Virtual Hosts > General > Index Files
Use Server Index Files: Set inherited index files named at the server level, or set the vhost’s own index file list. If set to
Addition
Copy Code
, it will add additional file names for index files to the server-level configuration.
Index Files: Default values are
index.html
Copy Code
and index.php
Copy Code
separated by ,
Copy Code
.
Auto Index: Set to
Yes
Copy Code
to enable Auto Index, set to No
Copy Code
to disable it, or set to Not Set
Copy Code
to inherit the server-level setting.
Auto Index URI: The script to generate the index, by default (when empty) will use
/usr/local/lsws/share/autoindex/default.php
Copy Code
These options will override the server-level configuration.
Enable/Disable Auto Index at the Context Level
If you want to disable Auto Index for all except for one or a few specific directories, you can achieve this with context settings.
Virtual Hosts > Context > +
Create a Static Context, and choose a URL. In this example, we will use
/test/
Copy Code
URI:
/test/
Copy Code
(do not miss the /
Copy Code
at end)
Location:
$DOC_ROOT/test/
Copy Code
. This can be an absolute path e.g. /home/domain.com/public_html/test/
Copy Code
or a relative path with $DOC_ROOT
Copy Code
or $VH_ROOT
Copy Code
e.g $DOC_ROOT/test/
Copy Code
or $VH_ROOT/public_html/test/
Copy Code
.
Accessible:
Yes
Copy Code
Index Files: Set the index file name for this context.
Auto Index: Enable, disable, or inherit Auto Index for this context.
How to Customize the Auto Index Page
This is the default Auto Index page:
The script used for Auto Index is
/usr/local/lsws/share/autoindex/default.php
Copy Code
. You can create your own script or edit the default one to further customize it.
For example, the following PHP code lists the files in the directory:
<?php
$list = scandir(getenv('LS_AI_PATH'));
echo "Directory to be indexed: " .getenv('LS_AI_PATH'). "<br>";
print_r($list);
Copy Code
The environment variable LS_AI_PATH is used to pass the directory that needs to be indexed to the script
[Looking for a solution to another query? We’re happy to help.]
Conclusion
In this article, we provide a quick and simple solution from our Support team to enable auto index in openlitespeed
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments