Question
How to change or reorder default index files (DirectoryIndex) for all websites on the server?
Answer
For Linux
Click here to reveal additional information
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.ini
using any text editor:[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
Click here to reveal additional information
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:windirsystem32inetsrvappcmd.exe set config $_ /section:defaultDocument /enabled:true /+files.[value=`'test.php`'] } }
-
If the following error appears:
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:windirsystem32inetsrvappcmd.exe clear config $_ /section:defaultDocument } }
-