Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to change or reorder default index files (DirectoryIndex) for all websites on the server?
Answer
For Linux
Note: In the following example, index.php is set as a priority. All newly created domains will have the new directoryIndex afterwards.
-
Connect to the server via SSH;
-
Add the following lines to
/usr/local/psa/admin/conf/panel.iniusing any text editor:CONFIG_TEXT: [webserver]
directoryIndex = "index.php index.html index.cgi index.pl index.xhtml index.htm index.shtml" -
Reconfigure all existing domains:
# plesk bin domain -l | while read i; do plesk repair web $i -y; done
For Windows
Note: In the following example test.php file is set as a priority:
-
Connect to the server via RDP.
-
Open PowerShell command line
-
Run one of the following commands depending on the requirements:
-
Set up the "test.php" file as a default document file for all existing domains:
Note: change the "test.php" file in the command below to the correct one.
PS > plesk bin site -l | % { if ( $_ ) { &$env:windir\system32\inetsrv\appcmd.exe set config $_ /section:defaultDocument /enabled:true /+files.[value=`'test.php`'] } }
-
If the following error appears:
CONFIG_TEXT: ERROR ( message:New add object missing required attributes. Cannot add duplicate collection entry of type 'add' with unique key attribute 'value' set to 'main.php'. )
then such file is already present in the default documents list. Modify file priority manually in IIS > hostname > Sites > example.com > Default Documents.
-
Reset the customization of Default Documents to default for all domains:
PS > plesk bin site -l | % { if ( $_ ) { &$env:windir\system32\inetsrv\appcmd.exe clear config $_ /section:defaultDocument } }
-
Comments
Is there a way to set this on a per-site basis, that doesn't involve htaccess or the additional server directives area? Sometimes additional directives are incompatible with other things Plesk does due to where in the virtual host config they're included.
Please sign in to leave a comment.