How to change the default index for all websites on Plesk?

Started by Suhitha, Dec 21, 2025, 11:47 PM

Previous topic - Next topic

Suhitha

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

                              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.

1.Connect to the server via SSH;

2.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"

3.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:

1.Connect to the server via RDP.

2.Open PowerShell command line

3.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:

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 } }