How To Add Custom DirectoryIndex Settings to Apache VHosts ========================================================== Be default, the DirectoryIndex setting in the Apache vhosts created by InterWorx include ``index.html`` and ``index.php``. However, if additional index file extensions are required, it is possible to customize the vhosts to include them. Customizing the DirectoryIndex settings for a single domain can be completed either with a custom conf file in the domain's homedir, or via the InterWorx Config system. Adding custom DirectoryIndex settings globally can be completed using the InterWorx Config System. Using either method will allow the changes to persist if the domain is restored or imported from a backup. .. contents:: To Update a Single Domain ------------------------- The following examples will add index.htm as an accepted DirectoryIndex. Using A Custom Conf file ^^^^^^^^^^^^^^^^^^^^^^^^ #. Log in to the server at the CLI as root, either via SSH or from the terminal #. At the CLI, navigate to the domain's apache directory, replacing {unixuser} and {domain.com} with the corresponding information: .. code-block:: cd /home/{unixuser}/var/{domain.com}/apache #. Using a text editor, create a file that ends in .conf. The following example uses the Vim test editor .. note:: Since this example is adding ``index.html`` as an accepted DirectoryIndex, the file will be named ``htm.conf``. However, the only naming requirement is that the file ends with ``.conf``. The file can be named in any way, outside of that extension. .. code-block:: vim htm.conf #. Add the following line to that file, replacing {custom DirectoryIndex} with the corresponding information: .. code-block:: DirectoryIndex index.php index.html {custom DirectoryIndex} Example: .. code-block:: DirectoryIndex index.php index.html index.htm #. Save and exit the text editor #. Reload or Restart Apache .. code-block:: systemctl reload httpd or .. code-block:: systemctl restart httpd Using the InterWorx Config System ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #. Log in to the server at the CLI as root, either via SSH or from the terminal #. Check the current DirectoryIndex settings for the domain with the following, replacing {domain.com} with the corresponding information: .. code-block:: ~iworx/bin/config.pex --get --domain {domain.com} --name HTTPD_DIRECTORY_INDEX Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --get --domain example.com --name HTTPD_DIRECTORY_INDEX index.php index.html [root@server ~]# #. Run the following command, replacing {domain.com} and {custom DirectoryIndex} with the corresponding information: .. code-block:: ~iworx/bin/config.pex --set --domain {domain.com} --name HTTPD_DIRECTORY_INDEX --value 'index.php index.html {custom DirectoryIndex}' Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --set --domain example.com --name HTTPD_DIRECTORY_INDEX --value 'index.php index.html index.htm' [root@server ~]# #. Check that the changes were made successfully, replacing {domain.com} with the corresponding information .. code-block:: ~iworx/bin/config.pex --get --domain {domain.com} --name HTTPD_DIRECTORY_INDEX Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --get --domain example.com --name HTTPD_DIRECTORY_INDEX index.php index.html index.htm [root@server ~]# #. Rewrite the vhost file for the domain, replacing {domain.com} with the corresponding information .. code-block:: ~iworx/bin/httpd.pex --write-vhost --domain {domain} #. Reload or Restart Apache .. code-block:: systemctl reload httpd or .. code-block:: systemctl restart httpd To Set a Custom DirectoryIndex Globally --------------------------------------- .. note:: This will add the custom DirectoryIndex both to existing vhosts, as well as the vhosts for any newly created domains on the server. The following examples will add index.html as an accepted DirectoryIndex #. Log in to the server at the CLI as root, either via SSH or from the terminal #. Check the current DirectoryIndex settings for the domain with the following: .. code-block:: ~iworx/bin/config.pex --get --global --name HTTPD_DIRECTORY_INDEX Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --get --global --name HTTPD_DIRECTORY_INDEX index.php index.html [root@server ~]# #. Run the following command, replacing {custom DirectoryIndex} with the corresponding information: .. code-block:: ~iworx/bin/config.pex --set --global --name HTTPD_DIRECTORY_INDEX --value 'index.php index.html {custom DirectoryIndex}' Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --set --global --name HTTPD_DIRECTORY_INDEX --value 'index.php index.html index.htm' [root@server ~]# #. Check that the changes were made successfully .. code-block:: ~iworx/bin/config.pex --get --global --name HTTPD_DIRECTORY_INDEX Example: .. code-block:: [root@server ~]# ~iworx/bin/config.pex --get --global --name HTTPD_DIRECTORY_INDEX index.php index.html index.htm [root@server ~]# #. Rewrite all of the vhosts on the server .. code-block:: ~iworx/bin/httpd.pex --write-vhosts-all #. Reload or Restart Apache .. code-block:: systemctl reload httpd or .. code-block:: systemctl restart http