Articles in this section

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

Plesk for Windows kb: how-to Plesk for Linux ABT: Group A

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:

    CONFIG_TEXT: [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:

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

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.